From 2672facd21c6bd30b6912091cefe666edc2541b4 Mon Sep 17 00:00:00 2001 From: Fabio Davel <fabio@studioworks.com.br> Date: Sun, 7 Jul 2024 21:26:08 -0300 Subject: [PATCH] Adds feature that automatically names routes. --- src/AdvancedRoute.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/AdvancedRoute.php b/src/AdvancedRoute.php index 473ed17..0dcd38f 100644 --- a/src/AdvancedRoute.php +++ b/src/AdvancedRoute.php @@ -72,6 +72,12 @@ public static function controller($path, $controllerClassName) { if (self::stringStartsWith($methodName, $httpMethod)) { Route::$httpMethod($slug_path, $controllerClassName . '@' . $methodName); + $routeName = strtolower(str_replace('Controller', '', substr($controllerClassName, strrpos($controllerClassName,"\\")+1))); + $routeName .= ".{$httpMethod}."; + $routeName .= str_replace($httpMethod, '', strtolower($methodName)); + + Route::$httpMethod($slug_path, $controllerClassName . '@' . $methodName)->name($routeName); + $route = new \stdClass(); $route->httpMethod = $httpMethod; $route->prefix = sprintf("Route::%-4s('%s',", $httpMethod, $slug_path);