I want to have a custom 500 error page. This can be done simply by creating a view in errors/500.blade.php
.
This is fine for production mode, but I no longer get the default exception/ debug pages when in debug mode (the one that looks grey and says "Whoops something went wrong").
Therefore, my question is: how can I have a custom 500 error page for production, but the original 500 error page when debug mode is true?
Simply add this code in \App\Exceptinons\Handler.php:
public function render($request, Exception $exception)
{
// Render well-known exceptions here
// Otherwise display internal error message
if(!env('APP_DEBUG', false)){
return view('errors.500');
} else {
return parent::render($request, $exception);
}
}
Or
public function render($request, Exception $exception)
{
// Render well-known exceptions here
// Otherwise display internal error message
if(app()->environment() === 'production') {
return view('errors.500');
} else {
return parent::render($request, $exception);
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With