ItemChestOpenLog.php 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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 \Carbon\Carbon $open_time 开启时间
  13. * @property int $open_quantity 开启数量
  14. * @property array $result_items 获得的物品列表,包含物品ID、数量等信息
  15. * @property bool $pity_triggered 是否触发保底机制(0:否, 1:是)
  16. * @property int $pity_content_id 触发保底的内容ID,外键关联kku_item_chest_contents表(可为空)
  17. * @property string $ip_address 操作的IP地址(用于安全审计)
  18. * @property string $device_info 设备信息(用于安全审计)
  19. * @property \Carbon\Carbon $created_at 创建时间
  20. * field end
  21. */
  22. class ItemChestOpenLog extends ModelCore
  23. {
  24. /**
  25. * 与模型关联的表名
  26. *
  27. * @var string
  28. */
  29. protected $table = 'item_chest_open_logs';
  30. /**
  31. * 指示模型是否应该被打上时间戳
  32. * 由于这是日志表,只需要创建时间,不需要更新时间
  33. *
  34. * @var bool
  35. */
  36. public $timestamps = true;
  37. /**
  38. * 更新时间戳字段名
  39. * 设置为null表示不使用updated_at字段
  40. *
  41. * @var string|null
  42. */
  43. const UPDATED_AT = null;
  44. // attrlist start
  45. protected $fillable = [
  46. 'id',
  47. 'user_id',
  48. 'chest_id',
  49. 'open_time',
  50. 'open_quantity',
  51. 'result_items',
  52. 'pity_triggered',
  53. 'pity_content_id',
  54. 'ip_address',
  55. 'device_info',
  56. ];
  57. // attrlist end
  58. /**
  59. * 应该被转换为原生类型的属性
  60. *
  61. * @var array
  62. */
  63. protected $casts = [
  64. 'user_id' => 'integer',
  65. 'chest_id' => 'integer',
  66. 'open_quantity' => 'integer',
  67. 'result_items' => 'json',
  68. 'pity_triggered' => 'boolean',
  69. 'pity_content_id' => 'integer',
  70. 'open_time' => 'datetime',
  71. 'created_at' => 'datetime',
  72. ];
  73. /**
  74. * 获取关联的宝箱
  75. *
  76. * @return BelongsTo
  77. */
  78. public function chest(): BelongsTo
  79. {
  80. return $this->belongsTo(Item::class, 'chest_id');
  81. }
  82. }