<?php

use Illuminate\Support\Facades\Route;
use Stancl\Tenancy\Middleware\InitializeTenancyByDomain;
use Stancl\Tenancy\Middleware\PreventAccessFromCentralDomains;
use Modules\SpecialAttendance\Http\Controllers\Api\V11\DeductionApiController;


if (! in_array(url('/'), config('tenancy.central_domains')) && config('app.mood') === 'Saas' && isModuleActive('Saas')) {

    $middleware = [
        'api', 'cors', 'TimeZone', 'MaintenanceMode',
        InitializeTenancyByDomain::class,
        PreventAccessFromCentralDomains::class,
    ];

} else {
    $middleware = ['api', 'cors', 'TimeZone', 'MaintenanceMode'];
}

Route::middleware($middleware)->group(
    function () {
        Route::group(['middleware' => ['auth:sanctum', 'cors'], 'prefix' => 'V11'], function () {
            Route::controller(DeductionApiController::class)
                ->prefix('deductions')
                ->group(function () {
                    Route::get('/', 'index');
                    Route::post('/appeal/{id}', 'appeal');
                });
        });
    });
