FarmGodBuff.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. namespace App\Module\Farm\Models;
  3. use Illuminate\Database\Eloquent\Model;
  4. use Illuminate\Database\Eloquent\Relations\BelongsTo;
  5. /**
  6. * 神灵加持模型
  7. * field start
  8. * @property int $id 主键ID
  9. * @property int $user_id 用户ID
  10. * @property int $buff_type buff类型:1丰收之神,2雨露之神,3屠草之神,4拭虫之神
  11. * @property string $expire_time 过期时间
  12. * @property \Carbon\Carbon $created_at 创建时间
  13. * @property \Carbon\Carbon $updated_at 更新时间
  14. * field end
  15. */
  16. class FarmGodBuff extends Model
  17. {
  18. /**
  19. * 与模型关联的表名
  20. *
  21. * @var string
  22. */
  23. protected $table = 'farm_god_buffs';
  24. /**
  25. * 可批量赋值的属性
  26. *
  27. * @var array
  28. */
  29. protected $fillable = [
  30. 'user_id',
  31. 'buff_type',
  32. 'expire_time',
  33. ];
  34. /**
  35. * 应该被转换为日期的属性
  36. *
  37. * @var array
  38. */
  39. protected $dates = [
  40. 'expire_time',
  41. 'created_at',
  42. 'updated_at',
  43. ];
  44. /**
  45. * 获取关联的用户农场
  46. *
  47. * @return BelongsTo
  48. */
  49. public function farmUser(): BelongsTo
  50. {
  51. return $this->belongsTo(FarmUser::class, 'user_id', 'user_id');
  52. }
  53. }