<?php

use App\Modules\HR\PermissionRequests\Controllers\PermissionRequestsPageController;
use Illuminate\Support\Facades\Route;

Route::prefix('hr/permission-requests')
    ->name('hr.permission-requests.')
    ->middleware('module:hr')
    ->group(function () {
        Route::get('/', [PermissionRequestsPageController::class, 'index'])
            ->middleware('can:permission_requests.view')
            ->name('index');
        Route::get('/create', [PermissionRequestsPageController::class, 'create'])
            ->middleware('can:permission_requests.create')
            ->name('create');
        Route::post('/', [PermissionRequestsPageController::class, 'store'])
            ->middleware('can:permission_requests.create')
            ->name('store');
        Route::post('/{permissionRequest}/approve', [PermissionRequestsPageController::class, 'approve'])
            ->whereNumber('permissionRequest')
            ->middleware('can:permission_requests.review')
            ->name('approve');
        Route::post('/{permissionRequest}/reject', [PermissionRequestsPageController::class, 'reject'])
            ->whereNumber('permissionRequest')
            ->middleware('can:permission_requests.review')
            ->name('reject');
    });
