From 56766b007295fbf495b6a03866200e671b208130 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Viktor=20Sz=C3=A9pe?= Date: Thu, 26 Oct 2023 17:30:41 +0200 Subject: [PATCH 1/3] Handle unknown HTTP method in MediaController --- src/Http/Controllers/MediaController.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Http/Controllers/MediaController.php b/src/Http/Controllers/MediaController.php index 332a54c1..0ebebad9 100644 --- a/src/Http/Controllers/MediaController.php +++ b/src/Http/Controllers/MediaController.php @@ -27,6 +27,7 @@ public function __invoke(Request $request): JsonResponse 'GET' => new JsonResponse($field->paginate($request, $model)), 'POST' => new JsonResponse($field->upload($request, $model), JsonResponse::HTTP_CREATED), 'DELETE' => new JsonResponse(['deleted' => $field->prune($request, $model, $request->input('ids', []))]), + default => throw new \Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException(), }; } } From 3f0e306cd3876e18f7c2d4182e353f6d21d4d2c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Viktor=20Sz=C3=A9pe?= Date: Thu, 26 Oct 2023 20:50:44 +0200 Subject: [PATCH 2/3] Import class --- src/Http/Controllers/MediaController.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Http/Controllers/MediaController.php b/src/Http/Controllers/MediaController.php index 0ebebad9..803131d1 100644 --- a/src/Http/Controllers/MediaController.php +++ b/src/Http/Controllers/MediaController.php @@ -5,6 +5,7 @@ use Illuminate\Http\JsonResponse; use Illuminate\Http\Request; use Illuminate\Support\Facades\Gate; +use Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException; class MediaController extends Controller { @@ -27,7 +28,7 @@ public function __invoke(Request $request): JsonResponse 'GET' => new JsonResponse($field->paginate($request, $model)), 'POST' => new JsonResponse($field->upload($request, $model), JsonResponse::HTTP_CREATED), 'DELETE' => new JsonResponse(['deleted' => $field->prune($request, $model, $request->input('ids', []))]), - default => throw new \Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException(), + default => throw new MethodNotAllowedHttpException(), }; } } From 508f7e2be08f5391e1f3caee8a617629222942b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Viktor=20Sz=C3=A9pe?= Date: Thu, 26 Oct 2023 21:19:16 +0200 Subject: [PATCH 3/3] Add exception parameter --- src/Http/Controllers/MediaController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Http/Controllers/MediaController.php b/src/Http/Controllers/MediaController.php index 803131d1..9b5cc933 100644 --- a/src/Http/Controllers/MediaController.php +++ b/src/Http/Controllers/MediaController.php @@ -28,7 +28,7 @@ public function __invoke(Request $request): JsonResponse 'GET' => new JsonResponse($field->paginate($request, $model)), 'POST' => new JsonResponse($field->upload($request, $model), JsonResponse::HTTP_CREATED), 'DELETE' => new JsonResponse(['deleted' => $field->prune($request, $model, $request->input('ids', []))]), - default => throw new MethodNotAllowedHttpException(), + default => throw new MethodNotAllowedHttpException(['GET', 'POST', 'DELETE']), }; } }