show 500 or 404 page in laravel

Solutions on MaxInterview for show 500 or 404 page in laravel by the best coders in the world

showing results for - "show 500 or 404 page in laravel"
Nicolò
23 Feb 2020
1public function render($request, Exception $e)
2{
3
4    // 404 page when a model is not found
5    if ($e instanceof ModelNotFoundException) {
6        return response()->view('errors.404', [], 404);
7    }
8
9    if ($this->isHttpException($e)) {
10        return $this->renderHttpException($e);
11    } else {
12        // Custom error 500 view on production
13        if (app()->environment() == 'production') {
14            return response()->view('errors.500', [], 500);
15        }
16        return parent::render($request, $e);
17    }
18
19}
20