<?php

use App\Modules\HR\Training\Controllers\TrainingController;
use Illuminate\Support\Facades\Route;

Route::prefix('hr/training')->name('hr.training.')->middleware(['module:hr', 'can:training.view'])->group(function (): void {
    Route::get('/courses', [TrainingController::class, 'courses'])->name('courses.index');
    Route::post('/courses', [TrainingController::class, 'storeCourse'])->middleware('can:training.create')->name('courses.store');
    Route::put('/courses/{course}', [TrainingController::class, 'updateCourse'])->middleware('can:training.update')->name('courses.update');
    Route::delete('/courses/{course}', [TrainingController::class, 'destroyCourse'])->middleware('can:training.manage')->name('courses.destroy');
    Route::get('/sessions', [TrainingController::class, 'sessions'])->name('sessions.index');
    Route::post('/courses/{course}/sessions', [TrainingController::class, 'storeSession'])->middleware('can:training.create')->name('sessions.store');
    Route::put('/sessions/{session}', [TrainingController::class, 'updateSession'])->middleware('can:training.update')->name('sessions.update');
    Route::delete('/sessions/{session}', [TrainingController::class, 'destroySession'])->middleware('can:training.manage')->name('sessions.destroy');
    Route::post('/sessions/{session}/enroll', [TrainingController::class, 'enroll'])->middleware('can:training.manage')->name('sessions.enroll');
});
