ItemPityTime.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. namespace App\Module\GameItems\Models;
  3. use Illuminate\Database\Eloquent\Relations\BelongsTo;
  4. use UCore\ModelCore;
  5. /**
  6. * 宝箱保底计数
  7. *
  8. * field start
  9. * @property int $id 记录ID,主键
  10. * @property int $user_id 用户ID
  11. * @property int $chest_id 宝箱ID,外键关联kku_item_items表
  12. * @property int $chest_content_id 宝箱内容ID,外键关联kku_item_chest_contents表
  13. * @property int $current_count 当前计数,每开启一次宝箱增加1
  14. * @property string $last_reset_time 上次重置时间(可用于周期性重置)
  15. * @property \Carbon\Carbon $created_at 创建时间
  16. * @property \Carbon\Carbon $updated_at 更新时间
  17. * field end
  18. */
  19. class ItemPityTime extends ModelCore
  20. {
  21. /**
  22. * 与模型关联的表名
  23. *
  24. * @var string
  25. */
  26. protected $table = 'item_pity_times';
  27. // attrlist start
  28. protected $fillable = [
  29. 'id',
  30. 'user_id',
  31. 'chest_id',
  32. 'chest_content_id',
  33. 'current_count',
  34. 'last_reset_time',
  35. ];
  36. // attrlist end
  37. /**
  38. * 应该被转换为原生类型的属性
  39. *
  40. * @var array
  41. */
  42. protected $casts = [
  43. 'current_count' => 'integer',
  44. ];
  45. /**
  46. * 获取关联的宝箱
  47. *
  48. * @return BelongsTo
  49. */
  50. public function chest(): BelongsTo
  51. {
  52. return $this->belongsTo(Item::class, 'chest_id');
  53. }
  54. }