Skip to content

Commit

Permalink
Merge pull request #35 from fabiodavel/master
Browse files Browse the repository at this point in the history
Adds feature that automatically names routes.
  • Loading branch information
lesichkovm authored Jul 8, 2024
2 parents 40594c0 + 2672fac commit 9fb6ca9
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/AdvancedRoute.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 9fb6ca9

Please sign in to comment.