<?php

use Illuminate\Support\Facades\Route;

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider and all of them will
| be assigned to the "web" middleware group. Make something great!
|
*/

Route::get('/', function () {
    return redirect('/login');
});

Route::middleware('auth')->group(function () {
    // ! <---------------------------Employee Routes--------------------------->
    Route::middleware(['employee'])->group(function () {
        // ? Dashboard Routes
        Route::get('/dashboard', [App\Http\Controllers\Employee\DashboardController::class, 'index'])->name('dashboard');
        Route::get('/history/{result}', [App\Http\Controllers\Employee\DashboardController::class, 'historyDetail'])->name('employee.history');

        // ? Employee Profile Routes
        Route::controller(App\Http\Controllers\Employee\ProfileController::class)->group(function () {
            Route::get('/profile', 'index')->name('employee.profile');
            Route::get('/profile/setting', 'edit')->name('employee.profile.setting');
            Route::patch('/profile/setting', 'update')->name('employee.profile.setting.update');
        });

        // ? Employee Account Setting Routes
        Route::controller(App\Http\Controllers\Employee\SettingController::class)->group(function () {
            Route::get('/profile/account', 'index')->name('employee.profile.account');
            Route::patch('/profile/account', 'updateEmail')->name('employee.profile.email.update');
            Route::put('/profile/account', 'updatePassword')->name('employee.profile.password.update');
        });

        // ? User Management Routes
        Route::get('users', [App\Http\Controllers\Employee\UserManagementController::class, 'index'])->name('employee.users');
        Route::get('users/employee/create', [App\Http\Controllers\Employee\UserManagementController::class, 'create'])->name('employee.users.create');
        Route::post('users/employee/create', [App\Http\Controllers\Employee\UserManagementController::class, 'store'])->name('employee.users.store');
        Route::get('user/{user}', [App\Http\Controllers\Employee\UserManagementController::class, 'edit'])->name('employee.users.edit');
        Route::put('user/{user}', [App\Http\Controllers\Employee\UserManagementController::class, 'update'])->name('employee.users.update');

        // ? Weight Management Routes
        Route::controller(App\Http\Controllers\Employee\WeightController::class)->group(function () {
            Route::get('weights', 'index')->name('weights');
            Route::get('weights/create', 'create')->name('weights.create');
            Route::post('weights/create', 'store')->name('weights.store');
            Route::get('weights/{weights}', 'edit')->name('weights.edit');
            Route::put('weights{weights}', 'update')->name('weights.update');
            Route::delete('weights/{weights}', 'destroy')->name('weights.delete');
        });

        // ? Personality Management Routes
        Route::controller(App\Http\Controllers\Employee\PersonalityController::class)->group(function () {
            Route::get('personalities', 'index')->name('personalities');
            Route::get('personalities/create', 'create')->name('personalities.create');
            Route::post('personalities/create', 'store')->name('personalities.store');
            Route::get('personalities/{personalities}', 'edit')->name('personalities.edit');
            Route::put('personalities/{personalities}', 'update')->name('personalities.update');
            Route::delete('personalities/{personalities}', 'destroy')->name('personalities.delete');
        });

        // ? Career Management Routes
        Route::controller(App\Http\Controllers\Employee\CareerController::class)->group(function () {
            Route::get('careers', 'index')->name('careers');
            Route::get('careers/create', 'create')->name('careers.create');
            Route::post('careers/create', 'store')->name('careers.store');
            Route::get('careers/{careers}', 'edit')->name('careers.edit');
            Route::put('careers/{careers}', 'update')->name('careers.update');
            Route::delete('careers/{careers}', 'destroy')->name('careers.delete');
        });

        // ? Department Management Routes
        Route::controller(App\Http\Controllers\Employee\DepartmentController::class)->group(function () {
            Route::get('departments', 'index')->name('departments');
            Route::get('departments/create', 'create')->name('departments.create');
            Route::post('departments/create', 'store')->name('departments.store');
            Route::get('departments/{departments}', 'edit')->name('departments.edit');
            Route::put('departments/{departments}', 'update')->name('departments.update');
            Route::delete('departments/{departments}', 'destroy')->name('departments.delete');
        });

        // ? Rule Management Routes
        Route::controller(App\Http\Controllers\Employee\RuleController::class)->group(function () {
            Route::get('rules', 'index')->name('rules');
            Route::get('rules/graph', 'graph')->name('graph');
            Route::get('rules/create', 'create')->name('rules.create');
            Route::post('rules/create', 'store')->name('rules.store');
            Route::get('rules/{rules}', 'edit')->name('rules.edit');
            Route::put('rules/{rules}', 'update')->name('rules.update');
            Route::delete('rules/{rules}', 'destroy')->name('rules.delete');
        });

        // ? Statement Management Routes
        Route::controller(\App\Http\Controllers\Employee\StatementController::class)->group(function () {
            Route::get('statements', 'index')->name('statements');
            Route::get('statements/create', 'create')->name('statements.create');
            Route::post('statements/create', 'store')->name('statements.store');
            Route::get('statements/{statements}', 'edit')->name('statements.edit');
            Route::put('statements/{statements}', 'update')->name('statements.update');
            Route::delete('statements/{statements}', 'destroy')->name('statements.delete');
        });

        Route::get('theory', [\App\Http\Controllers\Theory\DempsterController::class, 'index'])->name('employee.theory');
        Route::controller(App\Http\Controllers\Function\LaborController::class)->group(function () {
            Route::get('/laboratory', 'quest')->name('labor.quest');
            Route::post('/calculator', 'calculator')->name('labor.calculator');
        });
    });

    // ! <---------------------------Student Routes--------------------------->
    // ? Student Home Routes
    Route::get('home', [App\Http\Controllers\Student\DashboardController::class, 'index'])->name('student.dashboard');

    //? Student Profle Routes
    Route::controller(App\Http\Controllers\Student\ProfileController::class)->group(function () {
        Route::get('/myprofile', 'index')->name('student.profile');
        Route::get('/myprofile/setting', 'edit')->name('student.profile.setting');
        Route::patch('/myprofile/setting', 'update')->name('student.profile.setting.update');
    });

    // ? Student Account Setting Routes
    Route::controller(App\Http\Controllers\Student\SettingController::class)->group(function () {
        Route::get('/myprofile/account', 'index')->name('student.profile.account');
        Route::patch('/myprofile/account', 'updateEmail')->name('student.profile.email.update');
        Route::put('/myprofile/account', 'updatePassword')->name('student.profile.password.update');
    });

    // ? Student Personality Information
    Route::get('personality', [\App\Http\Controllers\Student\PersonalityController::class, 'index'])->name('student.personality');
    Route::get('personality/{slug}', [\App\Http\Controllers\Student\PersonalityController::class, 'view'])->name('student.personality.detail');

    // ? Student Result Routes
    Route::get('result', [\App\Http\Controllers\Student\ResultController::class, 'index'])->name('student.result');
    Route::get('/quest/history', [App\Http\Controllers\Student\ResultController::class, 'resultList'])->name('student.quest.history');
    Route::get('/quest/history/{result}', [App\Http\Controllers\Student\ResultController::class, 'resultDetail'])->name('student.quest.history.show');

    // ? Student Quisionnare Routes
    Route::controller(\App\Http\Controllers\Student\QuisionnareController::class)->group(function () {
        Route::get('start', 'index')->name('student.quisionnare.start');
        Route::get('quest', 'quest')->name('student.quisionnare.quest');
        Route::post('quest', 'store')->name('student.quisionnare.quest.store');
    });
});

require __DIR__ . '/auth.php';
