From 54b73e29d39de3f4742c6b2152889c93a2dba990 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?N=C3=A9stor=20D=C3=ADaz=20Valencia?= Date: Mon, 8 Jan 2024 11:48:01 +0100 Subject: [PATCH] Update ControllerDecorator.php for Laravel 9 and 10 compatibility (#266) References #265 265 --- src/Decorators/ControllerDecorator.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Decorators/ControllerDecorator.php b/src/Decorators/ControllerDecorator.php index 3fc4eaf..54f8d70 100644 --- a/src/Decorators/ControllerDecorator.php +++ b/src/Decorators/ControllerDecorator.php @@ -70,9 +70,9 @@ public function __invoke(string $method) $response = $this->run($method); - if ($this->hasMethod('jsonResponse') && $request->expectsJson()) { + if ($this->hasMethod('jsonResponse') && ($request->expectsJson() || $request->isJson())) { $response = $this->callMethod('jsonResponse', [$response, $request]); - } elseif ($this->hasMethod('htmlResponse') && ! $request->expectsJson()) { + } elseif ($this->hasMethod('htmlResponse') && ! ($request->expectsJson() || $request->isJson())) { $response = $this->callMethod('htmlResponse', [$response, $request]); }