TaskList.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. namespace App\Models;
  3. use Illuminate\Database\Eloquent\Model;
  4. class TaskList extends Model
  5. {
  6. protected $table = 'task_list';
  7. protected $fillable = ['user_id', 'title', 'role_id', 'content', 'created_at', 'updated_at', 'state', 'image', 'init_content', 'keyword', 'sd_image',
  8. 'desc', 'sd_id', 'surplus_diamond', 'nickname', 'plot', 'is_handpick', 'sort', 'pinyin_content', 'pdf_path', 'image_path','is_piny'];
  9. public static $state = [
  10. 0 => '已提交',
  11. 1 => '生成中',
  12. 2 => '故事已生成',
  13. 3 => '标题已生成',
  14. 4 => '插画已生成',
  15. 5 => '内容已编辑',
  16. 6 => '已完成',
  17. ];
  18. public function role()
  19. {
  20. return $this->hasOne(UserRole::class, 'id', 'role_id');
  21. }
  22. public function userData()
  23. {
  24. return $this->hasOne(User::class, 'id', 'user_id');
  25. }
  26. public function getCreatedAtAttribute($value)
  27. {
  28. $dateTime = new \DateTime($value);
  29. // 格式化时间
  30. $formattedTime = $dateTime->format('Y-m-d H:i:s');
  31. return $formattedTime;
  32. }
  33. public function getUpdatedAtAttribute($value)
  34. {
  35. $dateTime = new \DateTime($value);
  36. // 格式化时间
  37. $formattedTime = $dateTime->format('Y-m-d H:i:s');
  38. return $formattedTime;
  39. }
  40. }