<?php

use Illuminate\Support\Facades\Route;
use Modules\Payroll\Http\Controllers\CpfAccountsController;
use Modules\Payroll\Http\Controllers\EmployeeAdvanceController;
use Modules\Payroll\Http\Controllers\EmployeeLoanController;
use Modules\Payroll\Http\Controllers\PayrollCycleController;

Route::middleware(['api.auth'])->group(function () {

    Route::prefix('payroll')->group(function () {
        Route::apiResource('payroll-cycles', PayrollCycleController::class)->except('destroy');

        Route::apiResource('employees-loans', EmployeeLoanController::class)->except('destroy');
        Route::post('employees-loans/{employeeLoan}/approve', [EmployeeLoanController::class, 'approve']);
        Route::post('employees-loans/{employeeLoan}/cancel', [EmployeeLoanController::class, 'cancel']);

        Route::apiResource('employees-advances', EmployeeAdvanceController::class)->except('destroy');
        Route::post('employees-advances/{employeeAdvance}/approve', [EmployeeAdvanceController::class, 'approve']);
        Route::post('employees-advances/{employeeAdvance}/cancel', [EmployeeAdvanceController::class, 'cancel']);

        Route::apiResource('cpf-accounts', CpfAccountsController::class)->except('destroy');
    });
});
