laravel-advanced-route icon indicating copy to clipboard operation
laravel-advanced-route copied to clipboard

Automatically naming routes

Open fabiodavel opened this issue 2 years ago • 1 comments

Could add a way to name the routes automatically.

Exemplo: controller.method.action

if (self::stringStartsWith($methodName, $httpMethod)) {

// NEW CODE
        $routeName = strtolower(str_replace('Controller', '', substr($controllerClassName, strrpos($controllerClassName,"\\")+1)));
        $routeName .= ".{$httpMethod}.";
        $routeName .= str_replace($httpMethod, '', strtolower($methodName));
// END NEW CODE

// CHANGED LINE
        Route::$httpMethod($slug_path, $controllerClassName . '@' . $methodName)->name($routeName);

        $route = new \stdClass();
        $route->httpMethod = $httpMethod;
        $route->prefix = sprintf("Route::%-4s('%s',", $httpMethod, $slug_path);
        $route->target = $controllerClassName . '@' . $methodName;
        $routes[] = $route;
        break;
}

fabiodavel avatar Aug 29 '23 02:08 fabiodavel

@fabiodavel is this request to add a new feature? If this is correct, can you send it as a pull request, as its not clear what is being changed.

lesichkovm avatar Aug 29 '23 06:08 lesichkovm

PR merged

lesichkovm avatar Jul 09 '24 03:07 lesichkovm