123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- <?php
- namespace App\Models;
- use Illuminate\Database\Eloquent\Model;
- class TaskList extends Model
- {
- protected $table = 'task_list';
- protected $fillable = ['user_id', 'title', 'role_id', 'content', 'created_at', 'updated_at', 'state', 'image', 'init_content', 'keyword', 'sd_image',
- 'desc', 'sd_id', 'surplus_diamond', 'nickname', 'plot', 'is_handpick', 'sort', 'pinyin_content', 'pdf_path', 'image_path','is_piny'];
- public static $state = [
- 0 => '已提交',
- 1 => '生成中',
- 2 => '故事已生成',
- 3 => '标题已生成',
- 4 => '插画已生成',
- 5 => '内容已编辑',
- 6 => '已完成',
- ];
- public function role()
- {
- return $this->hasOne(UserRole::class, 'id', 'role_id');
- }
- public function userData()
- {
- return $this->hasOne(User::class, 'id', 'user_id');
- }
- public function getCreatedAtAttribute($value)
- {
- $dateTime = new \DateTime($value);
- // 格式化时间
- $formattedTime = $dateTime->format('Y-m-d H:i:s');
- return $formattedTime;
- }
- public function getUpdatedAtAttribute($value)
- {
- $dateTime = new \DateTime($value);
- // 格式化时间
- $formattedTime = $dateTime->format('Y-m-d H:i:s');
- return $formattedTime;
- }
- }
|