| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- <?php
- namespace App\Module\Task\Models;
- use UCore\ModelCore;
- use Illuminate\Database\Eloquent\Relations\HasMany;
- /**
- * 任务分类模型
- *
- * field start
- * @property int $id 主键
- * @property string $name 分类名称
- * @property string $code 分类编码(唯一)
- * @property string $description 分类描述
- * @property int $sort_order 排序顺序
- * @property \Carbon\Carbon $created_at 创建时间
- * @property \Carbon\Carbon $updated_at 更新时间
- * field end
- */
- class TaskCategory extends ModelCore
- {
- /**
- * 与模型关联的表名
- * 注意:由于数据库配置中有kku_前缀,但实际表名是task_categories,所以需要覆盖前缀
- *
- * @var string
- */
- protected $table = 'task_categories';
- /**
- * 获取表名(覆盖父类方法以禁用前缀)
- *
- * @return string
- */
- public function getTable()
- {
- return $this->table;
- }
- /**
- * 主键
- *
- * @var string
- */
- protected $primaryKey = 'id';
- // attrlist start
- protected $fillable = [
- 'id',
- 'name',
- 'code',
- 'description',
- 'sort_order',
- ];
- // attrlist end
- /**
- * 获取该分类下的所有任务
- *
- * @return HasMany
- */
- public function tasks(): HasMany
- {
- return $this->hasMany(Task::class, 'category_id', 'id');
- }
- }
|