How to return 404 in Laravel
Sometimes our users will end up where they shouldn’t, i.e., on a page that doesn’t exist or one that they shouldn’t have access to.
In this situation, it is best to return the 404 code and show the error page.
In Laravel, this is very simple. You don’t have to do much thinking. Just use the abort()
helper with 404
as the first argument.
abort(404);
This should do the whole job and display a 404 page with a 404 response code.