404 Is usually the right response for a missing resource.
If you want to send back a custom 404 page for that case, you could use
Response::make($content, $statusCode) from the docs.
You could create a view and then call $view->render() on it to get the content.
The other way to do it is, instead of calling
App::abort(404); you could throw a custom exception (like say,
UserNotFoundException) and register your own handler for that exception.
Thanks for the response. I understand your proposed solutions. However, the specific challenge for me here is a bit different. I want a custom 404 response, but must really give this response at the specific point in code marked with a comment.
If I don't do this, the closure used in
Route::bind will return null, and throw an exception, as the closure in
Route::get expects an argument of type
Sign in to participate in this thread!
We'd like to thank these amazing companies for supporting us