Technically there is a difference between a not found (with a status code 404) and a not allowed (with a status code 405)
Laravel give you a lot of options for handling exceptions.
An option that can be useful for you is Rendering Exceptions
use Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException;
/**
* Register the exception handling callbacks for the application.
*
* @return void
*/
public function register()
{
// This will throw a 404 / not found exception if we try to render a MethodNotAllowedHttpException (like if we do a GET on a POST url.
$this->renderable(function (MethodNotAllowedHttpException $e, $request) {
abort(404);
});
}
faisal liked this reply
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community