| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- <?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
- {
- /**
- * 与模型关联的表名
- *
- * @var string
- */
- protected $table = 'task_categories';
- /**
- * 主键
- *
- * @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');
- }
- }
|