TaskCategory.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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 $name 分类名称
  11. * @property string $code 分类编码(唯一)
  12. * @property string $description 分类描述
  13. * @property int $sort_order 排序顺序
  14. * @property \Carbon\Carbon $created_at 创建时间
  15. * @property \Carbon\Carbon $updated_at 更新时间
  16. * field end
  17. */
  18. class TaskCategory extends ModelCore
  19. {
  20. /**
  21. * 与模型关联的表名
  22. *
  23. * @var string
  24. */
  25. protected $table = 'task_categories';
  26. /**
  27. * 主键
  28. *
  29. * @var string
  30. */
  31. protected $primaryKey = 'id';
  32. // attrlist start
  33. protected $fillable = [
  34. 'id',
  35. 'name',
  36. 'code',
  37. 'description',
  38. 'sort_order',
  39. ];
  40. // attrlist end
  41. /**
  42. * 获取该分类下的所有任务
  43. *
  44. * @return HasMany
  45. */
  46. public function tasks(): HasMany
  47. {
  48. return $this->hasMany(Task::class, 'category_id', 'id');
  49. }
  50. }