Skip to content

Commit

Permalink
Merge pull request #167 from conedevelopment/szepeviktor-patch-3
Browse files Browse the repository at this point in the history
Handle unknown HTTP method in MediaController
  • Loading branch information
iamgergo authored Oct 27, 2023
2 parents 092f931 + 508f7e2 commit 44e1491
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/Http/Controllers/MediaController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -27,6 +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(['GET', 'POST', 'DELETE']),
};
}
}

0 comments on commit 44e1491

Please sign in to comment.