FarmGodBuff.php 1.2 KB

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