Fixed handler for reports

Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
snipe 2025-02-19 05:03:26 +00:00
parent 82d8e1b0a9
commit 35a89de6dd

View file

@ -126,14 +126,17 @@ class Handler extends ExceptionHandler
// The only alternative is to set that at *each* route, which is crazypants // The only alternative is to set that at *each* route, which is crazypants
if ($e instanceof \Illuminate\Database\Eloquent\ModelNotFoundException) { if ($e instanceof \Illuminate\Database\Eloquent\ModelNotFoundException) {
$model_name = last(explode('\\', $e->getModel())); $model_name = last(explode('\\', $e->getModel()));
$route_base = str_plural(strtolower(last(explode('\\', $e->getModel())))); $route = str_plural(strtolower(last(explode('\\', $e->getModel())))).'.index';
// Sigh. Fucking laravel. // Sigh. Fucking laravel.
if ($route_base == 'assets') { if ($route == 'assets.index') {
$route_base = 'hardware'; $route = 'hardware.index';
} elseif ($route == 'reporttemplates.index') {
$route = 'reports/custom';
} }
return redirect() return redirect()
->route($route_base.'.index') ->route($route)
->withError(trans('general.generic_model_not_found', ['model' => $model_name])); ->withError(trans('general.generic_model_not_found', ['model' => $model_name]));
} }