CourseWork/routes/web.php
2024-06-24 22:04:44 +04:00

62 lines
3.0 KiB
PHP

<?php
use App\Http\Controllers\ProfileController;
use App\Http\Middleware\AdminAction;
use App\Http\Middleware\StudentAction;
use App\Http\Middleware\TeacherAction;
use Illuminate\Support\Facades\Route;
use App\Http\Controllers\GradeController;
use App\Http\Controllers\GradeSubjectController;
use App\Http\Controllers\GradeTeacherController;
use App\Http\Controllers\LessonController;
use App\Http\Controllers\ScoreController;
use App\Http\Controllers\StudentController;
use App\Http\Controllers\SubjectController;
use App\Http\Controllers\SubjectTeacherController;
use App\Http\Controllers\TeacherController;
Route::get('/', function () {
return redirect()->route('profile.edit');
});
Route::get('/dashboard', function () {
return view('dashboard');
})->middleware(['auth', 'verified'])->name('dashboard');
Route::middleware('auth')->group(function () {
Route::get('/profile', [ProfileController::class, 'edit'])->name('profile.edit');
Route::patch('/profile', [ProfileController::class, 'update'])->name('profile.update');
Route::delete('/profile', [ProfileController::class, 'destroy'])->name('profile.destroy');
Route::resources([
'grades' => GradeController::class,
'subjects' => SubjectController::class,
'students' => StudentController::class,
'teachers' => TeacherController::class,
'grades.lessons' => LessonController::class,
]);
Route::middleware([AdminAction::class])->group(function () {
Route::resource('teachers.subjects', SubjectTeacherController::class)->except('index');
Route::resource('teachers.subjects.grades', GradeTeacherController::class)->except('index', 'show');
Route::resource('grades.subjects', GradeSubjectController::class)->except('index', 'show');
});
Route::middleware([TeacherAction::class])->group(function () {
Route::get('lessons/{lesson}/scores', [ScoreController::class, 'show'])->name('lessons.scores.show');
Route::put('lessons/{lesson}/scores', [ScoreController::class, 'update'])->name('lessons.scores.update');
Route::get('grades/{grade}/subjects/{subject}/journal', [GradeSubjectController::class, 'journal'])->name('grades.subjects.journal');
Route::get('grades/{grade}/list-students', [GradeController::class, 'listStudents'])->name('list-students');
Route::get('grades/{grade}/subjects/{subject}/journal/export-excel', [GradeSubjectController::class, 'exportToExcel'])->name('export-excel');
});
Route::middleware([StudentAction::class])->group(function () {
Route::get('export-pdf', [SubjectController::class, 'exportToPDF'])->name('export-pdf');
Route::get('subjects/{subject}/student-scores', [StudentController::class, 'scores'])->name('student-scores');
Route::get('student-debts', [StudentController::class, 'debts'])->name('student-debts');
Route::get('teachers/{teacher}/subjects', [SubjectTeacherController::class, 'index'])->name('teachers.subjects.index');
});
});
require __DIR__.'/auth.php';