TaskReward.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. namespace App\Module\Task\Models;
  3. use UCore\ModelCore;
  4. use Illuminate\Database\Eloquent\Relations\BelongsTo;
  5. /**
  6. * 任务奖励模型
  7. *
  8. * field start
  9. * @property int $id 主键
  10. * @property int $task_id 任务ID,外键关联task_tasks表
  11. * @property string $reward_type 奖励类型(item, currency, experience, feature_unlock等)
  12. * @property string $reward_param1 奖励参数1(如物品类型、货币类型等)
  13. * @property string $reward_param2 奖励参数2(如物品ID、货币ID等)
  14. * @property int $quantity 奖励数量
  15. * @property object|array $extra_data 额外数据(JSON格式)
  16. * @property int $sort_order 排序权重(数值越大越靠前)
  17. * @property \Carbon\Carbon $created_at 创建时间
  18. * @property \Carbon\Carbon $updated_at 更新时间
  19. * field end
  20. */
  21. class TaskReward extends ModelCore
  22. {
  23. /**
  24. * 与模型关联的表名
  25. *
  26. * @var string
  27. */
  28. protected $table = 'task_rewards';
  29. /**
  30. * 主键
  31. *
  32. * @var string
  33. */
  34. protected $primaryKey = 'id';
  35. /**
  36. * 应该被转换为原生类型的属性
  37. *
  38. * @var array
  39. */
  40. protected $casts = [
  41. 'extra_data' => 'array',
  42. ];
  43. // attrlist start
  44. protected $fillable = [
  45. 'id',
  46. 'task_id',
  47. 'reward_type',
  48. 'reward_param1',
  49. 'reward_param2',
  50. 'quantity',
  51. 'extra_data',
  52. 'sort_order',
  53. ];
  54. // attrlist end
  55. /**
  56. * 获取关联的任务
  57. *
  58. * @return BelongsTo
  59. */
  60. public function task(): BelongsTo
  61. {
  62. return $this->belongsTo(Task::class, 'task_id', 'id');
  63. }
  64. }