| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- <?php
- namespace App\Module\GameItems\Models;
- use Illuminate\Database\Eloquent\Relations\BelongsTo;
- use UCore\ModelCore;
- /**
- * 宝箱开启记录
- *
- * field start
- * @property int $id 记录ID,主键
- * @property int $user_id 用户ID
- * @property int $chest_id 宝箱ID,外键关联kku_item_items表
- * @property string $open_time 开启时间
- * @property int $open_quantity 开启数量
- * @property object|array $result_items 获得的物品列表,包含物品ID、数量等信息
- * @property int $pity_triggered 是否触发保底机制(0:否, 1:是)
- * @property int $pity_content_id 触发保底的内容ID,外键关联kku_item_chest_contents表(可为空)
- * @property string $ip_address 操作的IP地址(用于安全审计)
- * @property string $device_info 设备信息(用于安全审计)
- * @property \Carbon\Carbon $created_at 创建时间
- * field end
- */
- class ItemChestOpenLog extends ModelCore
- {
- /**
- * 与模型关联的表名
- *
- * @var string
- */
- protected $table = 'item_chest_open_logs';
- // attrlist start
- protected $fillable = [
- 'id',
- 'user_id',
- 'chest_id',
- 'open_time',
- 'open_quantity',
- 'result_items',
- 'pity_triggered',
- 'pity_content_id',
- 'ip_address',
- 'device_info',
- ];
- // attrlist end
- /**
- * 应该被转换为日期的属性
- *
- * @var array
- */
- protected $dates = [
- 'open_time',
- 'created_at',
- ];
- /**
- * 应该被转换为原生类型的属性
- *
- * @var array
- */
- protected $casts = [
- 'results' => \App\Module\GameItems\Casts\ChestOpenResultsCast::class,
- 'quantity' => 'integer',
- 'pity_triggered' => 'boolean',
- ];
- /**
- * 获取关联的宝箱
- *
- * @return BelongsTo
- */
- public function chest(): BelongsTo
- {
- return $this->belongsTo(ItemItem::class, 'chest_id');
- }
- /**
- * 获取触发保底的宝箱内容(如果有)
- *
- * @return BelongsTo
- */
- public function pityContent(): BelongsTo
- {
- return $this->belongsTo(ItemChestContent::class, 'pity_content_id');
- }
- }
|