withRouting( web: __DIR__.'/../routes/web.php', api: __DIR__.'/../routes/api.php', commands: __DIR__.'/../routes/console.php', health: '/up', ) ->withMiddleware(function (Middleware $middleware) { $middleware->encryptCookies(except: ['appearance', 'sidebar_state']); $middleware->web(append: [ HandleAppearance::class, HandleInertiaRequests::class, AddLinkHeadersForPreloadedAssets::class, ]); }) ->withExceptions(function (Exceptions $exceptions) { $exceptions->reportable(function (Throwable $e) { $level = match (true) { $e instanceof Error => App\LogLevelEnum::CRITICAL, $e instanceof RuntimeException => App\LogLevelEnum::ERROR, $e instanceof InvalidArgumentException => App\LogLevelEnum::WARNING, default => App\LogLevelEnum::ERROR, }; App\Events\ExceptionOccurred::dispatch( $e, $level, $e->getMessage(), [] ); }); })->create();