From 6f8f5e2746d408dd5d1b59262dc944b13ee72e1d Mon Sep 17 00:00:00 2001 From: Lance Pioch Date: Sat, 11 May 2024 21:48:36 -0400 Subject: [PATCH] =?UTF-8?q?Don=E2=80=99t=20handle=20livewire?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Exceptions/DisplayException.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) 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()); }