Category.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. namespace App\Models;
  3. // use Illuminate\Contracts\Authenticate\MustVerifyEmail;
  4. use DateTimeInterface;
  5. use Illuminate\Database\Eloquent\Factories\HasFactory;
  6. use Illuminate\Database\Eloquent\Model;
  7. use Illuminate\Database\Eloquent\SoftDeletes;
  8. use Illuminate\Foundation\Auth\User as Authenticatable;
  9. use Illuminate\Notifications\Notifiable;
  10. use Laravel\Sanctum\HasApiTokens;
  11. use Tymon\JWTAuth\Contracts\JWTSubject;
  12. class Category extends Model
  13. {
  14. use HasFactory, SoftDeletes;
  15. // 设置表名
  16. protected $table = 'js_project_category';
  17. /**
  18. * 日期时间的存储格式
  19. *
  20. * @var string
  21. */
  22. // protected $dateFormat = 'Y-m-d H:i:s';
  23. const CREATED_AT = 'create_time';
  24. const UPDATED_AT = 'update_time';
  25. // 自定义软删除字段 默认 deleted_at
  26. const DELETED_AT = 'delete_time';
  27. protected $dateFormat = 'U';
  28. /**
  29. * The attributes that are mass assignable.
  30. *
  31. * @var array<int, string>
  32. */
  33. protected $fillable = [];
  34. /**
  35. * The attributes that should be hidden for serialization.
  36. *
  37. * @var array<int, string>
  38. */
  39. protected $hidden = [];
  40. /**
  41. * The attributes that should be cast.
  42. *
  43. * @var array<string, string>
  44. */
  45. protected $casts = [
  46. // 'create_time' => 'datetime', //'datetime:Y-m-d H:i:s'
  47. // 'password' => 'hashed',
  48. ];
  49. protected function serializeDate(DateTimeInterface $date): string
  50. {
  51. return $date->format('Y-m-d H:i:s');
  52. }
  53. }