| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- <?php
- namespace App\Module\Task\Models;
- use UCore\ModelCore;
- use Illuminate\Database\Eloquent\Relations\BelongsTo;
- /**
- * 任务接取消耗模型
- *
- * field start
- * @property int $id 主键
- * @property int $task_id 任务ID,外键关联task_tasks表
- * @property string $cost_type 消耗类型(currency, item, energy, ticket等)
- * @property string $cost_param1 消耗参数1(如货币类型、物品类型等)
- * @property string $cost_param2 消耗参数2(如货币ID、物品ID等)
- * @property int $quantity 消耗数量
- * @property array $extra_data 额外数据(JSON格式)
- * @property int $sort_order 排序权重(数值越大越靠前)
- * @property \Carbon\Carbon $created_at 创建时间
- * @property \Carbon\Carbon $updated_at 更新时间
- * field end
- */
- class TaskCost extends ModelCore
- {
- /**
- * 与模型关联的表名
- *
- * @var string
- */
- protected $table = 'task_costs';
- /**
- * 主键
- *
- * @var string
- */
- protected $primaryKey = 'id';
- /**
- * 应该被转换为原生类型的属性
- *
- * @var array
- */
- protected $casts = [
- 'extra_data' => 'array',
- ];
- // attrlist start
- protected $fillable = [
- 'id',
- 'task_id',
- 'cost_type',
- 'cost_param1',
- 'cost_param2',
- 'quantity',
- 'extra_data',
- 'sort_order',
- ];
- // attrlist end
- /**
- * 获取关联的任务
- *
- * @return BelongsTo
- */
- public function task(): BelongsTo
- {
- return $this->belongsTo(Task::class, 'task_id', 'id');
- }
- }
|