diff --git a/app/Exceptions/DisplayException.php b/app/Exceptions/DisplayException.php index 3a74c5e87..d79fc2751 100644 --- a/app/Exceptions/DisplayException.php +++ b/app/Exceptions/DisplayException.php @@ -3,6 +3,7 @@ namespace App\Exceptions; use Exception; +use Filament\Notifications\Notification; use Illuminate\Http\Request; use Psr\Log\LoggerInterface; use Illuminate\Http\Response; @@ -47,8 +48,18 @@ class DisplayException extends PanelException implements HttpExceptionInterface * and then redirecting them back to the page that they came from. If the * request originated from an API hit, return the error in JSONAPI spec format. */ - public function render(Request $request): JsonResponse|RedirectResponse + public function render(Request $request) { + if (str($request->url())->contains('livewire')) { + Notification::make() + ->title(static::class) + ->body($this->getMessage()) + ->danger() + ->send(); + + return; + } + if ($request->expectsJson()) { return response()->json(Handler::toArray($this), $this->getStatusCode(), $this->getHeaders()); }