<?php

use Illuminate\Support\Facades\Route;

use App\Modules\HR\Leave\Http\Controllers\LeaveApplicationController;

Route::middleware(['auth','branch', 'module:leave'])
    ->prefix('leave')
    ->name('leave.')
    ->group(function () {

        // Employee list
        Route::get('applications', [LeaveApplicationController::class, 'index'])
            ->name('applications.index');

        // Employee leave detail page
        Route::get('applications/load-leave-types',[LeaveApplicationController::class, 'getLeaveTypes'])->name('applications.loadLeaveTypes');

        Route::get('applications/{employee}', [LeaveApplicationController::class, 'show'])
            ->name('applications.show');

        // Load employee leave history (datatable)
        Route::get('applications/{employee}/history', [LeaveApplicationController::class, 'history'])
            ->name('applications.history');


        // Store manual leave
        Route::post('applications/store', [LeaveApplicationController::class, 'store'])
            ->name('applications.store');

        // Load attendance preview
        Route::post('applications/attendance-preview', [LeaveApplicationController::class, 'attendancePreview'])
            ->name('applications.attendancePreview');


        Route::delete('applications/{leave}',[LeaveApplicationController::class, 'destroy'])->name('applications.destroy');

    });

