From 35a89de6dda54f7cdf3f6e8c5a93d920d43efb8b Mon Sep 17 00:00:00 2001 From: snipe Date: Wed, 19 Feb 2025 05:03:26 +0000 Subject: [PATCH] Fixed handler for reports Signed-off-by: snipe --- app/Exceptions/Handler.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php index 2c6d00548e..bcba923208 100644 --- a/app/Exceptions/Handler.php +++ b/app/Exceptions/Handler.php @@ -126,14 +126,17 @@ class Handler extends ExceptionHandler // 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())))); + $route = str_plural(strtolower(last(explode('\\', $e->getModel())))).'.index'; // Sigh. Fucking laravel. - if ($route_base == 'assets') { - $route_base = 'hardware'; + if ($route == 'assets.index') { + $route = 'hardware.index'; + } elseif ($route == 'reporttemplates.index') { + $route = 'reports/custom'; } + return redirect() - ->route($route_base.'.index') + ->route($route) ->withError(trans('general.generic_model_not_found', ['model' => $model_name])); }