| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- <?php
- namespace App\Module\Game\Models;
- use App\Module\Game\Enums\CONSUME_TYPE;
- use Illuminate\Database\Eloquent\Relations\BelongsTo;
- use UCore\ModelCore;
- /**
- * 消耗项
- *
- * field start
- * @property int $id 主键
- * @property int $group_id 消耗组ID,外键关联game_consume_groups表
- * @property int $consume_type 消耗类型(1:物品, 2:货币)
- * @property int $target_id 目标ID(物品ID、货币ID等,根据consume_type解释)
- * @property int $param1 参数1(根据consume_type不同含义,如物品的品质、货币的来源等)
- * @property int $param2 参数2(根据consume_type不同含义,如物品的绑定状态、货币的类型等)
- * @property int $quantity 数量
- * @property array $extra_data 额外数据(JSON格式,可存储特定消耗类型的额外参数)
- * @property \Carbon\Carbon $created_at 创建时间
- * @property \Carbon\Carbon $updated_at 更新时间
- * field end
- */
- class GameConsumeItem extends ModelCore
- {
- /**
- * 与模型关联的表名
- *
- * @var string
- */
- protected $table = 'game_consume_items';
- // attrlist start
- protected $fillable = [
- 'id',
- 'group_id',
- 'consume_type',
- 'target_id',
- 'param1',
- 'param2',
- 'quantity',
- 'extra_data',
- ];
- // attrlist end
- /**
- * 应该被转换为原生类型的属性
- *
- * @var array
- */
- protected $casts = [
- 'consume_type' => 'integer',
- 'target_id' => 'integer',
- 'param1' => 'integer',
- 'param2' => 'integer',
- 'quantity' => 'integer',
- 'extra_data' => 'json',
- ];
- /**
- * 获取消耗项所属的消耗组
- *
- * @return BelongsTo
- */
- public function consumeGroup(): BelongsTo
- {
- return $this->belongsTo(GameConsumeGroup::class, 'group_id', 'id');
- }
- }
|