<?php

// ── Memory override — must be FIRST line before anything loads ────
// Filament v5 + Livewire v4 RelationManagers are memory-heavy.
// 512M is the minimum viable for development.
// On cPanel production set this in .htaccess or php.ini instead.
ini_set('memory_limit', '512M');

// // Increase execution time — Livewire updates can be slow on
// // large relation managers with many actions
// ini_set('max_execution_time', '120');

use App\Http\Middleware\EnsureUserIsClient;
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([
            'client' => EnsureUserIsClient::class,
        ]);
    })
    ->withExceptions(function (Exceptions $exceptions) {
        //
    })->create();