Role.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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\Foundation\Auth\User as Authenticatable;
  8. use Illuminate\Notifications\Notifiable;
  9. use Laravel\Sanctum\HasApiTokens;
  10. use Tymon\JWTAuth\Contracts\JWTSubject;
  11. class Role extends Model
  12. {
  13. use HasFactory;
  14. // 设置表名
  15. protected $table = 'role';
  16. // 设置主键
  17. // public $primaryKey = 'id';
  18. /**
  19. * 自动生成时间戳
  20. */
  21. // public $timestamps = FALSE;
  22. const CREATED_AT = 'create_time';
  23. const UPDATED_AT = 'update_time';
  24. // 自定义软删除字段 默认 deleted_at
  25. // const DELETED_AT = 'delete_at';
  26. /**
  27. * 日期时间的存储格式
  28. *
  29. * @var string
  30. */
  31. // protected $dateFormat = 'Y-m-d H:i:s';
  32. /**
  33. * The attributes that are mass assignable.
  34. *
  35. * @var array<int, string>
  36. */
  37. protected $fillable = [];
  38. /**
  39. * The attributes that should be hidden for serialization.
  40. *
  41. * @var array<int, string>
  42. */
  43. protected $hidden = [];
  44. /**
  45. * The attributes that should be cast.
  46. *
  47. * @var array<string, string>
  48. */
  49. protected $casts = [
  50. // 'create_time' => 'datetime', //'datetime:Y-m-d H:i:s'
  51. // 'password' => 'hashed',
  52. ];
  53. protected function serializeDate(DateTimeInterface $date): string
  54. {
  55. return $date->format('Y-m-d H:i:s');
  56. }
  57. }