| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110 |
- <?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 $recipe_id 配方ID,外键关联kku_item_recipes表
- * @property object|array $materials 消耗的材料,以JSON格式存储
- * @property int $result_item_id 获得的物品ID,外键关联kku_item_items表
- * @property int $result_instance_id 获得的单独属性物品ID,外键关联kku_item_instances表(可为空)
- * @property int $result_quantity 获得的物品数量
- * @property int $is_success 是否成功(0:失败, 1:成功)
- * @property string $craft_time 合成时间
- * @property string $ip_address 操作的IP地址
- * @property string $device_info 设备信息
- * @property \Carbon\Carbon $created_at 创建时间
- * field end
- */
- class ItemCraftLog extends ModelCore
- {
- /**
- * 与模型关联的表名
- *
- * @var string
- */
- protected $table = 'item_craft_logs';
- // attrlist start
- protected $fillable = [
- 'id',
- 'user_id',
- 'recipe_id',
- 'materials',
- 'result_item_id',
- 'result_instance_id',
- 'result_quantity',
- 'is_success',
- 'craft_time',
- 'ip_address',
- 'device_info',
- ];
- // attrlist end
- /**
- * 可批量赋值的属性
- *
- * @var array
- */
- /**
- * 应该被转换为日期的属性
- *
- * @var array
- */
- protected $dates = [
- 'craft_time',
- 'created_at',
- ];
- /**
- * 应该被转换为原生类型的属性
- *
- * @var array
- */
- protected $casts = [
- 'is_success' => 'boolean',
- 'materials_used' => TransactionDetailsCast::class,
- 'result_quantity' => 'integer',
- ];
- /**
- * 获取关联的配方
- *
- * @return BelongsTo
- */
- public function recipe(): BelongsTo
- {
- return $this->belongsTo(ItemRecipe::class, 'recipe_id');
- }
- /**
- * 获取关联的结果物品
- *
- * @return BelongsTo
- */
- public function resultItem(): BelongsTo
- {
- return $this->belongsTo(Item::class, 'result_item_id');
- }
- /**
- * 获取关联的结果物品实例(如果有)
- *
- * @return BelongsTo
- */
- public function resultInstance(): BelongsTo
- {
- return $this->belongsTo(ItemInstance::class, 'result_instance_id');
- }
- }
|