I have a route of /path/{id}, and I want my controller to detect when the id is invalid and product a 404 error page. I tried using App::abort(404);
, but this doesn't produce a 404 error - just a generic exception. How do I make it generate a 404 page?
You have to use the Response::make or Response::view functions to generate a specific page. You can pass the error code as an argument to that. Like this:
Response::make("Page not found", 404);
Or to use a specific view, use:
return Response::view('404', array(), 404);
To display the view app/views/404.php with the http response code 404. Remember to replace the slashes with dots for the view name, so if your file is at app/views/errors/404.php, you will need to use the view name 'errors.404' for laravel to find it.
More information here: http://laravel.com/api/class-Illuminate.Support.Facades.Response.html