TaskCondition.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?php
  2. namespace App\Module\Task\Models;
  3. use UCore\ModelCore;
  4. use Illuminate\Database\Eloquent\Relations\HasMany;
  5. /**
  6. * 任务条件模型
  7. *
  8. * field start
  9. * @property int $id 主键
  10. * @property string $code 条件代码(唯一),如login, plant, harvest
  11. * @property string $name 条件名称,如登录游戏, 种植作物, 收获作物
  12. * @property string $description 条件描述
  13. * @property object|array $param_schema 参数模式,定义此条件需要的参数及其类型
  14. * @property string $handler_class 处理此条件的类名
  15. * @property int $is_active 是否激活(0:否, 1:是)
  16. * @property \Carbon\Carbon $created_at 创建时间
  17. * @property \Carbon\Carbon $updated_at 更新时间
  18. * field end
  19. */
  20. class TaskCondition extends ModelCore
  21. {
  22. /**
  23. * 与模型关联的表名
  24. *
  25. * @var string
  26. */
  27. protected $table = 'task_conditions';
  28. /**
  29. * 主键
  30. *
  31. * @var string
  32. */
  33. protected $primaryKey = 'id';
  34. /**
  35. * 应该被转换为原生类型的属性
  36. *
  37. * @var array
  38. */
  39. protected $casts = [
  40. 'param_schema' => 'array',
  41. 'is_active' => 'boolean',
  42. ];
  43. // attrlist start
  44. protected $fillable = [
  45. 'id',
  46. 'code',
  47. 'name',
  48. 'description',
  49. 'param_schema',
  50. 'handler_class',
  51. 'is_active',
  52. ];
  53. // attrlist end
  54. /**
  55. * 获取使用此条件的任务达成条件
  56. *
  57. * @return HasMany
  58. */
  59. public function achievementConditions(): HasMany
  60. {
  61. return $this->hasMany(TaskAchievementCondition::class, 'condition_id', 'id');
  62. }
  63. }