diff --git a/src/Common/GeneratorConfig.php b/src/Common/GeneratorConfig.php index dbef46588..d55f59708 100755 --- a/src/Common/GeneratorConfig.php +++ b/src/Common/GeneratorConfig.php @@ -289,8 +289,6 @@ public function loadDynamicVariables(CommandData &$commandData) $commandData->addDynamicVariable('$MODEL_NAME_PLURAL_SNAKE$', $this->mSnakePlural); $commandData->addDynamicVariable('$MODEL_NAME_DASHED$', $this->mDashed); $commandData->addDynamicVariable('$MODEL_NAME_PLURAL_DASHED$', $this->mDashedPlural); - $commandData->addDynamicVariable('$MODEL_NAME_SLASH$', $this->mSlash); - $commandData->addDynamicVariable('$MODEL_NAME_PLURAL_SLASH$', $this->mSlashPlural); $commandData->addDynamicVariable('$MODEL_NAME_HUMAN$', $this->mHuman); $commandData->addDynamicVariable('$MODEL_NAME_PLURAL_HUMAN$', $this->mHumanPlural); $commandData->addDynamicVariable('$FILES$', ''); @@ -368,10 +366,8 @@ public function prepareModelNames() $this->mCamelPlural = Str::camel($this->mPlural); $this->mSnake = Str::snake($this->mName); $this->mSnakePlural = Str::snake($this->mPlural); - $this->mDashed = str_replace('_', '-', Str::snake($this->mSnake)); - $this->mDashedPlural = str_replace('_', '-', Str::snake($this->mSnakePlural)); - $this->mSlash = str_replace('_', '/', Str::snake($this->mSnake)); - $this->mSlashPlural = str_replace('_', '/', Str::snake($this->mSnakePlural)); + $this->mDashed = Str::kebab($this->mName); + $this->mDashedPlural = Str::kebab($this->mPlural); $this->mHuman = Str::title(str_replace('_', ' ', Str::snake($this->mSnake))); $this->mHumanPlural = Str::title(str_replace('_', ' ', Str::snake($this->mSnakePlural))); } diff --git a/src/Generators/API/APIRoutesGenerator.php b/src/Generators/API/APIRoutesGenerator.php index 9a3d73a75..fa53c5515 100755 --- a/src/Generators/API/APIRoutesGenerator.php +++ b/src/Generators/API/APIRoutesGenerator.php @@ -45,8 +45,8 @@ public function generate() { $this->routeContents .= "\n\n".$this->routesTemplate; $existingRouteContents = file_get_contents($this->path); - if (Str::contains($existingRouteContents, "Route::resource('".$this->commandData->config->mSnakePlural."',")) { - $this->commandData->commandObj->info('Menu '.$this->commandData->config->mPlural.'is already exists, Skipping Adjustment.'); + if (Str::contains($existingRouteContents, "Route::resource('".$this->commandData->config->mDashedPlural."',")) { + $this->commandData->commandObj->info('Menu '.$this->commandData->config->mDashedPlural.'is already exists, Skipping Adjustment.'); return; } diff --git a/src/Generators/Scaffold/RoutesGenerator.php b/src/Generators/Scaffold/RoutesGenerator.php index 949196832..5c4fd64d1 100755 --- a/src/Generators/Scaffold/RoutesGenerator.php +++ b/src/Generators/Scaffold/RoutesGenerator.php @@ -36,8 +36,8 @@ public function generate() { $this->routeContents .= "\n\n".$this->routesTemplate; $existingRouteContents = file_get_contents($this->path); - if (Str::contains($existingRouteContents, "Route::resource('".$this->commandData->config->mSnakePlural."',")) { - $this->commandData->commandObj->info('Route '.$this->commandData->config->mPlural.' is already exists, Skipping Adjustment.'); + if (Str::contains($existingRouteContents, "Route::resource('".$this->commandData->config->mDashedPlural."',")) { + $this->commandData->commandObj->info('Route '.$this->commandData->config->mDashedPlural.' is already exists, Skipping Adjustment.'); return; } diff --git a/templates/api/routes/prefix_routes.stub b/templates/api/routes/prefix_routes.stub index 133e5b325..4df56d886 100644 --- a/templates/api/routes/prefix_routes.stub +++ b/templates/api/routes/prefix_routes.stub @@ -1,3 +1,3 @@ Route::group(['prefix' => '$RAW_ROUTE_PREFIX$'], function () { - Route::resource('$MODEL_NAME_PLURAL_SNAKE$', $NAMESPACE_API_CONTROLLER$\$MODEL_NAME$APIController::class); + Route::resource('$MODEL_NAME_PLURAL_DASHED$', $NAMESPACE_API_CONTROLLER$\$MODEL_NAME$APIController::class); }); diff --git a/templates/api/routes/routes.stub b/templates/api/routes/routes.stub index 2ce895fe8..ab707f741 100755 --- a/templates/api/routes/routes.stub +++ b/templates/api/routes/routes.stub @@ -1 +1 @@ -Route::resource('$MODEL_NAME_PLURAL_SNAKE$', $NAMESPACE_API_CONTROLLER$\$MODEL_NAME$APIController::class); +Route::resource('$MODEL_NAME_PLURAL_DASHED$', $NAMESPACE_API_CONTROLLER$\$MODEL_NAME$APIController::class); diff --git a/templates/scaffold/routes/prefix_routes.stub b/templates/scaffold/routes/prefix_routes.stub index d86a969aa..4bef065dc 100644 --- a/templates/scaffold/routes/prefix_routes.stub +++ b/templates/scaffold/routes/prefix_routes.stub @@ -1,3 +1,3 @@ Route::group(['prefix' => '$RAW_ROUTE_PREFIX$'], function () { - Route::resource('$MODEL_NAME_PLURAL_CAMEL$', $NAMESPACE_CONTROLLER$\$MODEL_NAME$Controller::class, ["as" => '$RAW_ROUTE_PREFIX$']); + Route::resource('$MODEL_NAME_PLURAL_DASHED$', $NAMESPACE_CONTROLLER$\$MODEL_NAME$Controller::class, ["as" => '$RAW_ROUTE_PREFIX$']); }); diff --git a/templates/scaffold/routes/routes.stub b/templates/scaffold/routes/routes.stub index 09d314092..3a9928683 100755 --- a/templates/scaffold/routes/routes.stub +++ b/templates/scaffold/routes/routes.stub @@ -1 +1 @@ -Route::resource('$MODEL_NAME_PLURAL_CAMEL$', $NAMESPACE_CONTROLLER$\$MODEL_NAME$Controller::class); +Route::resource('$MODEL_NAME_PLURAL_DASHED$', $NAMESPACE_CONTROLLER$\$MODEL_NAME$Controller::class);