PetRemouldLog.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <?php
  2. namespace App\Module\Pet\Models;
  3. use UCore\ModelCore;
  4. use Illuminate\Database\Eloquent\Relations\BelongsTo;
  5. /**
  6. * 宠物洗髓记录模型
  7. *
  8. * field start
  9. * @property int $id
  10. * @property int $pet_id
  11. * @property int $old_grade
  12. * @property int $new_grade
  13. * @property \Carbon\Carbon $remould_time
  14. * @property \Carbon\Carbon $created_at
  15. * field end
  16. */
  17. class PetRemouldLog extends ModelCore
  18. {
  19. /**
  20. * 与模型关联的表名
  21. *
  22. * @var string
  23. */
  24. protected $table = 'pet_remould_logs';
  25. /**
  26. * 指示模型是否应该被打上时间戳
  27. * 由于这是日志表,只需要创建时间,不需要更新时间
  28. *
  29. * @var bool
  30. */
  31. public $timestamps = true;
  32. /**
  33. * 更新时间戳字段名
  34. * 设置为null表示不使用updated_at字段
  35. *
  36. * @var string|null
  37. */
  38. const UPDATED_AT = null;
  39. // attrlist start
  40. protected $fillable = [
  41. 'id',
  42. 'pet_id',
  43. 'old_grade',
  44. 'new_grade',
  45. 'remould_time',
  46. ];
  47. // attrlist end
  48. /**
  49. * 应该被转换为原生类型的属性
  50. *
  51. * @var array
  52. */
  53. protected $casts = [
  54. 'pet_id' => 'integer',
  55. 'old_grade' => 'integer',
  56. 'new_grade' => 'integer',
  57. 'remould_time' => 'datetime',
  58. 'created_at' => 'datetime',
  59. ];
  60. /**
  61. * 获取关联的宠物
  62. *
  63. * @return BelongsTo
  64. */
  65. public function pet(): BelongsTo
  66. {
  67. return $this->belongsTo(PetUser::class, 'pet_id');
  68. }
  69. }