| 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 $reward_type 奖励类型(item, currency, experience, feature_unlock等)
- * @property string $reward_param1 奖励参数1(如物品类型、货币类型等)
- * @property string $reward_param2 奖励参数2(如物品ID、货币ID等)
- * @property int $quantity 奖励数量
- * @property object|array $extra_data 额外数据(JSON格式)
- * @property int $sort_order 排序权重(数值越大越靠前)
- * @property \Carbon\Carbon $created_at 创建时间
- * @property \Carbon\Carbon $updated_at 更新时间
- * field end
- */
- class TaskReward extends ModelCore
- {
- /**
- * 与模型关联的表名
- *
- * @var string
- */
- protected $table = 'task_rewards';
- /**
- * 主键
- *
- * @var string
- */
- protected $primaryKey = 'id';
- /**
- * 应该被转换为原生类型的属性
- *
- * @var array
- */
- protected $casts = [
- 'extra_data' => 'array',
- ];
- // attrlist start
- protected $fillable = [
- 'id',
- 'task_id',
- 'reward_type',
- 'reward_param1',
- 'reward_param2',
- 'quantity',
- 'extra_data',
- 'sort_order',
- ];
- // attrlist end
- /**
- * 获取关联的任务
- *
- * @return BelongsTo
- */
- public function task(): BelongsTo
- {
- return $this->belongsTo(Task::class, 'task_id', 'id');
- }
- }
|