Feat: CRUD категорий курсов
✅ CourseCategoryController (resource) ✅ CourseCategoryPolicy ✅ Маршруты: /admin/course-categories ✅ Blade-шаблоны: - index.blade.php (древовидный список) - create.blade.php - _row.blade.php (partial для дерева) ✅ Ссылка в сайдбаре ✅ Вложенность категорий (parent/children) ✅ Scope tree() для древовидной структуры Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
This commit is contained in:
@@ -38,4 +38,11 @@ class CourseCategory extends Model
|
||||
{
|
||||
return $this->hasMany(Course::class);
|
||||
}
|
||||
|
||||
public function scopeTree($query)
|
||||
{
|
||||
return $query->with(['children', 'children.children'])->withCount('courses')->orderBy('sort_order')->get()->filter(function($cat) {
|
||||
return is_null($cat->parent_id);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user