| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
- <?php
- namespace App\Module\GameItems\Models;
- use App\Module\GameItems\Casts\TransactionDetailsCast;
- use Illuminate\Database\Eloquent\Relations\BelongsTo;
- use UCore\ModelCore;
- /**
- * 物品分解记录
- *
- * field start
- * @property int $id 记录ID,主键
- * @property int $user_id 用户ID
- * @property int $item_id 被分解的物品ID,外键关联kku_item_items表
- * @property int $instance_id 被分解的单独属性物品ID,外键关联kku_item_instances表(可为空)
- * @property int $quantity 分解数量
- * @property int $rule_id 使用的分解规则ID,外键关联kku_item_dismantle_rules表
- * @property object|array $results 分解结果,包含获得的物品ID、数量等信息
- * @property string $dismantle_time 分解时间
- * @property string $ip_address 操作的IP地址
- * @property string $device_info 设备信息
- * @property \Carbon\Carbon $created_at 创建时间
- * field end
- */
- class ItemDismantleLog extends ModelCore
- {
- /**
- * 与模型关联的表名
- *
- * @var string
- */
- protected $table = 'item_dismantle_logs';
- // attrlist start
- protected $fillable = [
- 'id',
- 'user_id',
- 'item_id',
- 'instance_id',
- 'quantity',
- 'rule_id',
- 'results',
- 'dismantle_time',
- 'ip_address',
- 'device_info',
- ];
- // attrlist end
- /**
- * 应该被转换为日期的属性
- *
- * @var array
- */
- protected $dates = [
- 'dismantle_time',
- 'created_at',
- ];
- /**
- * 应该被转换为原生类型的属性
- *
- * @var array
- */
- protected $casts = [
- 'quantity' => 'integer',
- 'results' => TransactionDetailsCast::class,
- 'coin_returned' => 'integer',
- ];
- /**
- * 获取关联的物品
- *
- * @return BelongsTo
- */
- public function item(): BelongsTo
- {
- return $this->belongsTo(Item::class, 'item_id');
- }
- /**
- * 获取关联的物品实例(如果有)
- *
- * @return BelongsTo
- */
- public function instance(): BelongsTo
- {
- return $this->belongsTo(ItemInstance::class, 'instance_id');
- }
- /**
- * 获取关联的分解规则
- *
- * @return BelongsTo
- */
- public function rule(): BelongsTo
- {
- return $this->belongsTo(ItemDismantleRule::class, 'rule_id');
- }
- }
|