<?php

use Illuminate\Foundation\Application;
use Illuminate\Foundation\Configuration\Exceptions;
use Illuminate\Foundation\Configuration\Middleware;

return Application::configure(basePath: dirname(__DIR__))
    ->withRouting(
        web: __DIR__.'/../routes/web.php',
        commands: __DIR__.'/../routes/console.php',
        health: '/up',
    )
    ->withMiddleware(function (Middleware $middleware) {
        $middleware->alias([
            'admin.impersonate.password' => \App\Http\Middleware\AdminImpersonatePassword::class,
            'admin.project.access' => \App\Http\Middleware\EnsureAdminProjectAccess::class,
            'admin.activity.log' => \App\Http\Middleware\LogAdminActivity::class,
            'super.admin' => \App\Http\Middleware\EnsureSuperAdmin::class,
        ]);

        $middleware->validateCsrfTokens(except: [
            'webhook/payfastbd/activation',
            'webhook/payfastbd/wallet',
            'webhook/bondhonpay',
            'graphql/read-only',
        ]);
    })
    ->withExceptions(function (Exceptions $exceptions) {
        //
    })
    ->create();
