<?php

use App\Http\Controllers\Portal\NotificationController;
use App\Http\Controllers\Student\AnnouncementController;
use App\Http\Controllers\Student\AssignmentController;
use App\Http\Controllers\Student\AttendanceController;
use App\Http\Controllers\Student\CaseReportController;
use App\Http\Controllers\Student\ClubController;
use App\Http\Controllers\Student\DashboardController;
use App\Http\Controllers\Student\DisciplineController;
use App\Http\Controllers\Student\EventController;
use App\Http\Controllers\Student\ExamController;
use App\Http\Controllers\Student\FeeController;
use App\Http\Controllers\Student\MessageController;
use App\Http\Controllers\Student\ProfileController;
use App\Http\Controllers\Student\QuizController;
use App\Http\Controllers\Student\ReportCardController;
use App\Http\Controllers\Student\StudyMaterialController;
use App\Http\Controllers\Student\TimetableController;
use Illuminate\Support\Facades\Route;

Route::middleware(['auth', 'role:Student|Super Admin|Administrator'])
    ->prefix('student')
    ->name('student.')
    ->group(function () {
        Route::get('/', [DashboardController::class, 'index'])->name('dashboard');

        Route::get('profile', [ProfileController::class, 'show'])->name('profile.show');

        Route::get('materials', [StudyMaterialController::class, 'index'])->name('materials.index');
        Route::get('materials/{material}/download', [StudyMaterialController::class, 'download'])->name('materials.download');

        Route::get('assignments', [AssignmentController::class, 'index'])->name('assignments.index');
        Route::get('assignments/{assignment}', [AssignmentController::class, 'show'])->name('assignments.show');
        Route::post('assignments/{assignment}/submit', [AssignmentController::class, 'submit'])->name('assignments.submit');

        Route::get('quizzes', [QuizController::class, 'index'])->name('quizzes.index');
        Route::get('quizzes/{quiz}', [QuizController::class, 'show'])->name('quizzes.show');
        Route::post('quizzes/{quiz}/start', [QuizController::class, 'start'])->name('quizzes.start');
        Route::get('quizzes/{quiz}/take', [QuizController::class, 'take'])->name('quizzes.take');
        Route::post('quizzes/{quiz}/save', [QuizController::class, 'save'])->name('quizzes.save');

        Route::get('exams', [ExamController::class, 'index'])->name('exams.index');
        Route::get('announcements', [AnnouncementController::class, 'index'])->name('announcements.index');
        Route::get('attendance', [AttendanceController::class, 'index'])->name('attendance.index');
        Route::get('discipline', [DisciplineController::class, 'index'])->name('discipline.index');

        Route::get('timetable', [TimetableController::class, 'index'])->name('timetable.index');

        Route::get('messages', [MessageController::class, 'index'])->name('messages.index');
        Route::get('messages/create', [MessageController::class, 'create'])->name('messages.create');
        Route::post('messages', [MessageController::class, 'store'])->name('messages.store');
        Route::get('messages/{messageRecipient}', [MessageController::class, 'show'])->name('messages.show');
        Route::post('messages/{messageRecipient}/read', [MessageController::class, 'markRead'])->name('messages.read');

        Route::get('cases', [CaseReportController::class, 'index'])->name('cases.index');
        Route::get('cases/create', [CaseReportController::class, 'create'])->name('cases.create');
        Route::post('cases', [CaseReportController::class, 'store'])->name('cases.store');
        Route::get('cases/{case}', [CaseReportController::class, 'show'])->name('cases.show');

        Route::get('fees', [FeeController::class, 'index'])->name('fees.index');

        Route::get('report-cards', [ReportCardController::class, 'index'])->name('report-cards.index');
        Route::get('report-cards/{reportCard}', [ReportCardController::class, 'show'])->name('report-cards.show');
        Route::get('report-cards/{reportCard}/pdf', [ReportCardController::class, 'pdf'])->name('report-cards.pdf');

        Route::get('notifications', [NotificationController::class, 'index'])->name('notifications.index');
        Route::post('notifications/{id}/read', [NotificationController::class, 'markRead'])->name('notifications.read');
        Route::post('notifications/read-all', [NotificationController::class, 'markAllRead'])->name('notifications.read-all');

        Route::get('clubs', [ClubController::class, 'index'])->name('clubs.index');
        Route::get('clubs/{club}', [ClubController::class, 'show'])->name('clubs.show');
        Route::get('clubs/{club}/messages', [ClubController::class, 'messages'])->name('clubs.messages');
        Route::post('clubs/{club}/messages', [ClubController::class, 'storeMessage'])->name('clubs.messages.store');
        Route::post('clubs/{club}/messages/{messageId}/react', [ClubController::class, 'react'])->name('clubs.messages.react');

        Route::get('events/calendar', [EventController::class, 'calendar'])->name('events.calendar');
        Route::get('events/manage', [EventController::class, 'index'])->name('events.index');
        Route::get('events/create', [EventController::class, 'create'])->name('events.create');
        Route::post('events', [EventController::class, 'store'])->name('events.store');
        Route::get('events/{event}/edit', [EventController::class, 'edit'])->name('events.edit');
        Route::put('events/{event}', [EventController::class, 'update'])->name('events.update');
        Route::delete('events/{event}', [EventController::class, 'destroy'])->name('events.destroy');
    });
