group(function () { Route::get('/login', Login::class)->name('login'); }); // ==================== // Закрытые маршруты Route::middleware('auth')->group(function () { // ==================== // Выход из системы Route::get('/logout', function () { Auth::logout(); return redirect('login'); }); // ==================== // Просмотр курсов и занятий Route::view('/catalog', 'course-catalog')->name('catalog'); Route::get('/course/{course}', CourseHomePage::class)->name('course-index'); Route::get('/course/{course}/{lesson}', function (Course $course, $lesson) { $isExists = Lesson::query()->where('slug', $lesson)->where('course_id', $course->id)->exists(); if ($isExists) { return view('course-lesson', ['course' => $course, 'lesson' => $course->getLesson($lesson)]); } return abort(404); })->name('lesson'); // ==================== // Управление курсами Route::get('/manage/course', CourseManage::class)->name('course-manage'); Route::get('/manage/create/course', CourseCreate::class)->name('course-create')->can('course-create'); Route::middleware('can:course-update,course')->group(function () { Route::get('/manage/course/{course}', CourseEdit::class)->name('course-edit'); Route::get('/manage/course/{course}/lesson', LessonCreate::class)->name('lesson-create'); Route::get('/manage/course/{course}/lesson/{lesson}', LessonEdit::class)->name('lesson-edit'); }); });