ldc-boutique-cnc-sable/app/Exceptions/GlobalHandler.php

42 lines
1.3 KiB
PHP
Raw Permalink Normal View History

2026-06-14 21:32:07 +02:00
<?php
declare(strict_types=1);
namespace App\Exceptions;
use Domain\Exceptions\OrderTunnel\MissingOrderBuilderException;
use Illuminate\Foundation\Configuration\Exceptions;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Config;
final class GlobalHandler
{
private function __construct()
{
// * This class is not meant to be instantiated. *//
}
public static function afterAppBootstrap(Exceptions $exceptions): void
{
$exceptions->render(
fn (MissingOrderBuilderException $_, Request $__) => to_route('fo.sales.summary')
->withErrors(['tunnel' => trans(
'Your order session has expired or is invalid. Please review your basket.'
)])
);
$exceptions->render(function (CustomerNotEmployedException $_, Request $request) {
Auth::guard('frontend')->logout();
$request->session()->invalidate();
$request->session()->regenerateToken();
return to_route('fo.pages.home')->withErrors(
trans('Account blocked. Please contact your HR department or the St Laurent switchboard at :phone', [
'phone' => Config::string('ldc.headquarters_phone_reception'),
])
);
});
}
}