I'm also curious about this. Here is a quick workaround in the meantime.
$model = User:where('votes', '>', 100)->first();
if (!$model)
{
abort(500);
}
And then just create a file named 500.blade.php in the resources/views/errors directory. Laravel takes care of the rest. Check out the HTTP Exceptions section of the documentation.
In addition to creating resources/views/errors/500.blade.php, you can catch the ModelNotFoundException in app/Exceptions/Handler.php:
use Illuminate\Database\Eloquent\ModelNotFoundException;
// ...
public function render($request, Exception $e)
{
if($e instanceOf ModelNotFoundException)
{
abort(500);
}
return parent::render($request, $e);
}
(I'd do it with a 404 error.)
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community