mirror of
https://github.com/snipe/snipe-it.git
synced 2025-03-05 20:52:15 -08:00
Handle the not found errors with route model binding
Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
parent
644527c5a6
commit
989082d719
|
@ -122,6 +122,15 @@ class Handler extends ExceptionHandler
|
|||
}
|
||||
|
||||
|
||||
// This is traaaaash but it handles models that are not found while using route model binding :(
|
||||
// The only alternative is to set that at *each* route, which is crazypants
|
||||
if ($e instanceof \Illuminate\Database\Eloquent\ModelNotFoundException) {
|
||||
$model_name = last(explode('\\', $e->getModel()));
|
||||
$route_base = str_plural(strtolower(last(explode('\\', $e->getModel()))));
|
||||
return redirect()
|
||||
->route($route_base.'.index')
|
||||
->withError(trans('general.generic_model_not_found', ['model' => $model_name]));
|
||||
}
|
||||
|
||||
|
||||
if ($this->isHttpException($e) && (isset($statusCode)) && ($statusCode == '404' )) {
|
||||
|
|
Loading…
Reference in a new issue