<?php

use App\Modules\HR\Departments\Controllers\DepartmentPageController;
use Illuminate\Support\Facades\Route;

Route::prefix('hr/departments')->name('hr.departments.')->middleware('module:hr')->group(function () {
    Route::get('/', [DepartmentPageController::class, 'index'])
        ->middleware('can:departments.view')
        ->name('index');

    Route::get('/create', [DepartmentPageController::class, 'create'])
        ->middleware('can:departments.create')
        ->name('create');

    Route::post('/', [DepartmentPageController::class, 'store'])
        ->middleware('can:departments.create')
        ->name('store');

    Route::get('/{department}/edit', [DepartmentPageController::class, 'edit'])
        ->middleware('can:departments.update,department')
        ->name('edit');

    Route::put('/{department}', [DepartmentPageController::class, 'update'])
        ->middleware('can:departments.update,department')
        ->name('update');

    Route::delete('/{department}', [DepartmentPageController::class, 'destroy'])
        ->middleware('can:departments.delete,department')
        ->name('destroy');
});
