From bbabbe1b879de8a904ce534d2393a20ee1efb511 Mon Sep 17 00:00:00 2001 From: snipe Date: Tue, 4 Mar 2025 19:21:46 +0000 Subject: [PATCH 1/3] Nicer model name formatting on RMB model not found Signed-off-by: snipe --- app/Exceptions/Handler.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php index 21d8197eb..e4155d34f 100644 --- a/app/Exceptions/Handler.php +++ b/app/Exceptions/Handler.php @@ -125,7 +125,9 @@ 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())); + + // This gets the MVC model name from the exception and formats in a way that's less fugly + $model_name = implode("",preg_split('/(?=[A-Z])/',last(explode('\\', $e->getModel())))); $route = str_plural(strtolower(last(explode('\\', $e->getModel())))).'.index'; // Sigh. From d4e227f003a75030b80cf4011e0fe55ab6a06b94 Mon Sep 17 00:00:00 2001 From: snipe Date: Tue, 4 Mar 2025 19:29:09 +0000 Subject: [PATCH 2/3] Whitespace Signed-off-by: snipe --- app/Exceptions/Handler.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php index e4155d34f..180381b1f 100644 --- a/app/Exceptions/Handler.php +++ b/app/Exceptions/Handler.php @@ -127,7 +127,7 @@ class Handler extends ExceptionHandler if ($e instanceof \Illuminate\Database\Eloquent\ModelNotFoundException) { // This gets the MVC model name from the exception and formats in a way that's less fugly - $model_name = implode("",preg_split('/(?=[A-Z])/',last(explode('\\', $e->getModel())))); + $model_name = implode(" ", preg_split('/(?=[A-Z])/', last(explode('\\', $e->getModel())))); $route = str_plural(strtolower(last(explode('\\', $e->getModel())))).'.index'; // Sigh. From 63e4c424452ac49fddbc1e33ae4f9464bd4c7e38 Mon Sep 17 00:00:00 2001 From: snipe Date: Tue, 4 Mar 2025 19:33:17 +0000 Subject: [PATCH 3/3] Added strtolower Signed-off-by: snipe --- app/Exceptions/Handler.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php index 180381b1f..6e35f8217 100644 --- a/app/Exceptions/Handler.php +++ b/app/Exceptions/Handler.php @@ -127,7 +127,7 @@ class Handler extends ExceptionHandler if ($e instanceof \Illuminate\Database\Eloquent\ModelNotFoundException) { // This gets the MVC model name from the exception and formats in a way that's less fugly - $model_name = implode(" ", preg_split('/(?=[A-Z])/', last(explode('\\', $e->getModel())))); + $model_name = strtolower(implode(" ", preg_split('/(?=[A-Z])/', last(explode('\\', $e->getModel()))))); $route = str_plural(strtolower(last(explode('\\', $e->getModel())))).'.index'; // Sigh.