This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

ilanfir18653
ilanfir18653

When using Eloquent findOrFail() I want it to show the theme 404 page The first thing I tried was to add exception handler for ModelNotFoundException like this:

App::error(function(ModelNotFoundException $exception) {
    return Response::make(View::make('cms::404'), 404);
});

It works, but it shows the CMS/backend 404 page, not the theme 404. How do I return the theme 404 page?

ilanfir18653
ilanfir18653

Finally figured this out.

App::error(function(ModelNotFoundException $exception) {
    http_response_code(404);
    die($this->app->make('Cms\Classes\Controller')->run(404)->content());
});

I have to use http_response_code and die() the content here because the exception handler just outputs the returned value as string instead of using the response object, so returning a Response object displays the headers on page.

1-2 of 2

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.