I have a POST method in my route
Route::post('blog/{id}', 'AppHttpControllersBlogController@sendGrade');
And when I also specify POST in the request, then everything is fine
$.ajax({
type: 'POST',
But when the request is GET, I will get an error
The GET method is not supported for this route. Supported methods: POST.
This is all obvious, but is it possible to avoid this so that if there is a GET method in the request, then instead of this error I would get a 404 error?
As far as I understand it can be done in the controller. Right now I have something like this when the entry doesn’t exist
if(!$blog){
return abort(404);
}
Is it possible to do the same for the GET method?
2
Answers
in the exceptions/handler.php
add this route to your web.php file
this will work 100%