Skip to content

Commit 8405887

Browse files
committed
fix: change routes generation to kebab hyphen dashed type
1 parent 0b1160f commit 8405887

File tree

7 files changed

+10
-14
lines changed

7 files changed

+10
-14
lines changed

src/Common/GeneratorConfig.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -289,8 +289,6 @@ public function loadDynamicVariables(CommandData &$commandData)
289289
$commandData->addDynamicVariable('$MODEL_NAME_PLURAL_SNAKE$', $this->mSnakePlural);
290290
$commandData->addDynamicVariable('$MODEL_NAME_DASHED$', $this->mDashed);
291291
$commandData->addDynamicVariable('$MODEL_NAME_PLURAL_DASHED$', $this->mDashedPlural);
292-
$commandData->addDynamicVariable('$MODEL_NAME_SLASH$', $this->mSlash);
293-
$commandData->addDynamicVariable('$MODEL_NAME_PLURAL_SLASH$', $this->mSlashPlural);
294292
$commandData->addDynamicVariable('$MODEL_NAME_HUMAN$', $this->mHuman);
295293
$commandData->addDynamicVariable('$MODEL_NAME_PLURAL_HUMAN$', $this->mHumanPlural);
296294
$commandData->addDynamicVariable('$FILES$', '');
@@ -368,10 +366,8 @@ public function prepareModelNames()
368366
$this->mCamelPlural = Str::camel($this->mPlural);
369367
$this->mSnake = Str::snake($this->mName);
370368
$this->mSnakePlural = Str::snake($this->mPlural);
371-
$this->mDashed = str_replace('_', '-', Str::snake($this->mSnake));
372-
$this->mDashedPlural = str_replace('_', '-', Str::snake($this->mSnakePlural));
373-
$this->mSlash = str_replace('_', '/', Str::snake($this->mSnake));
374-
$this->mSlashPlural = str_replace('_', '/', Str::snake($this->mSnakePlural));
369+
$this->mDashed = Str::kebab($this->mName);
370+
$this->mDashedPlural = Str::kebab($this->mPlural);
375371
$this->mHuman = Str::title(str_replace('_', ' ', Str::snake($this->mSnake)));
376372
$this->mHumanPlural = Str::title(str_replace('_', ' ', Str::snake($this->mSnakePlural)));
377373
}

src/Generators/API/APIRoutesGenerator.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ public function generate()
4545
{
4646
$this->routeContents .= "\n\n".$this->routesTemplate;
4747
$existingRouteContents = file_get_contents($this->path);
48-
if (Str::contains($existingRouteContents, "Route::resource('".$this->commandData->config->mSnakePlural."',")) {
49-
$this->commandData->commandObj->info('Menu '.$this->commandData->config->mPlural.'is already exists, Skipping Adjustment.');
48+
if (Str::contains($existingRouteContents, "Route::resource('".$this->commandData->config->mDashedPlural."',")) {
49+
$this->commandData->commandObj->info('Menu '.$this->commandData->config->mDashedPlural.'is already exists, Skipping Adjustment.');
5050

5151
return;
5252
}

src/Generators/Scaffold/RoutesGenerator.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ public function generate()
3636
{
3737
$this->routeContents .= "\n\n".$this->routesTemplate;
3838
$existingRouteContents = file_get_contents($this->path);
39-
if (Str::contains($existingRouteContents, "Route::resource('".$this->commandData->config->mSnakePlural."',")) {
40-
$this->commandData->commandObj->info('Route '.$this->commandData->config->mPlural.' is already exists, Skipping Adjustment.');
39+
if (Str::contains($existingRouteContents, "Route::resource('".$this->commandData->config->mDashedPlural."',")) {
40+
$this->commandData->commandObj->info('Route '.$this->commandData->config->mDashedPlural.' is already exists, Skipping Adjustment.');
4141

4242
return;
4343
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
Route::group(['prefix' => '$RAW_ROUTE_PREFIX$'], function () {
2-
Route::resource('$MODEL_NAME_PLURAL_SNAKE$', $NAMESPACE_API_CONTROLLER$\$MODEL_NAME$APIController::class);
2+
Route::resource('$MODEL_NAME_PLURAL_DASHED$', $NAMESPACE_API_CONTROLLER$\$MODEL_NAME$APIController::class);
33
});

templates/api/routes/routes.stub

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Route::resource('$MODEL_NAME_PLURAL_SNAKE$', $NAMESPACE_API_CONTROLLER$\$MODEL_NAME$APIController::class);
1+
Route::resource('$MODEL_NAME_PLURAL_DASHED$', $NAMESPACE_API_CONTROLLER$\$MODEL_NAME$APIController::class);
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
Route::group(['prefix' => '$RAW_ROUTE_PREFIX$'], function () {
2-
Route::resource('$MODEL_NAME_PLURAL_CAMEL$', $NAMESPACE_CONTROLLER$\$MODEL_NAME$Controller::class, ["as" => '$RAW_ROUTE_PREFIX$']);
2+
Route::resource('$MODEL_NAME_PLURAL_DASHED$', $NAMESPACE_CONTROLLER$\$MODEL_NAME$Controller::class, ["as" => '$RAW_ROUTE_PREFIX$']);
33
});

templates/scaffold/routes/routes.stub

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Route::resource('$MODEL_NAME_PLURAL_CAMEL$', $NAMESPACE_CONTROLLER$\$MODEL_NAME$Controller::class);
1+
Route::resource('$MODEL_NAME_PLURAL_DASHED$', $NAMESPACE_CONTROLLER$\$MODEL_NAME$Controller::class);

0 commit comments

Comments
 (0)