Missing model record show message and redirect index page..

This commit is contained in:
Cüneyt Şentürk 2021-03-17 12:22:05 +03:00
parent 5e7f8faeba
commit 777e1d15d6
2 changed files with 23 additions and 11 deletions

View File

@ -100,8 +100,19 @@ class Handler extends ExceptionHandler
return response()->json(['error' => 'Not Found'], 404); return response()->json(['error' => 'Not Found'], 404);
} }
// normal 404 view page feedback try {
return response()->view('errors.404', [], 404); $names = explode('.', $request->route()->getName());
$names[count($names) - 1] = 'index';
$route = route(implode('.', $names));
flash(trans('errors.message.record'))->warning()->important();
return redirect($route);
} catch (\Exception $e) {
// normal 404 view page feedback
return response()->view('errors.404', [], 404);
}
} }
if ($exception instanceof FatalThrowableError) { if ($exception instanceof FatalThrowableError) {

View File

@ -3,21 +3,22 @@
return [ return [
'title' => [ 'title' => [
'403' => 'Oops! Forbidden Access', '403' => 'Oops! Forbidden Access',
'404' => 'Oops! Page not found', '404' => 'Oops! Page not found',
'500' => 'Oops! Something went wrong', '500' => 'Oops! Something went wrong',
], ],
'header' => [ 'header' => [
'403' => '403 Forbidden', '403' => '403 Forbidden',
'404' => '404 Not Found', '404' => '404 Not Found',
'500' => '500 Internal Server Error', '500' => '500 Internal Server Error',
], ],
'message' => [ 'message' => [
'403' => 'You can not access this page.', '403' => 'You can not access this page.',
'404' => 'We could not find the page you were looking for.', '404' => 'We could not find the page you were looking for.',
'500' => 'We will work on fixing that right away.', '500' => 'We will work on fixing that right away.',
'record' => 'We could not find the record you were looking for.',
], ],
]; ];