Don’t handle livewire

This commit is contained in:
Lance Pioch 2024-05-11 21:48:36 -04:00
parent 9fc46b9ae5
commit 6f8f5e2746

View File

@ -3,6 +3,7 @@
namespace App\Exceptions; namespace App\Exceptions;
use Exception; use Exception;
use Filament\Notifications\Notification;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Psr\Log\LoggerInterface; use Psr\Log\LoggerInterface;
use Illuminate\Http\Response; 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 * 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. * 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()) { if ($request->expectsJson()) {
return response()->json(Handler::toArray($this), $this->getStatusCode(), $this->getHeaders()); return response()->json(Handler::toArray($this), $this->getStatusCode(), $this->getHeaders());
} }