diff --git a/src/Commands/stubs/route-provider.stub b/src/Commands/stubs/route-provider.stub index 585a69146..cf72681fb 100644 --- a/src/Commands/stubs/route-provider.stub +++ b/src/Commands/stubs/route-provider.stub @@ -7,6 +7,8 @@ use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvi class $CLASS$ extends ServiceProvider { + protected string $name = '$MODULE$'; + /** * Called before routes are registered. * @@ -23,7 +25,6 @@ class $CLASS$ extends ServiceProvider public function map(): void { $this->mapApiRoutes(); - $this->mapWebRoutes(); } @@ -34,7 +35,7 @@ class $CLASS$ extends ServiceProvider */ protected function mapWebRoutes(): void { - Route::middleware('web')->group(module_path('$MODULE$', '$WEB_ROUTES_PATH$')); + Route::middleware('web')->group(module_path($this->name, '$WEB_ROUTES_PATH$')); } /** @@ -44,6 +45,6 @@ class $CLASS$ extends ServiceProvider */ protected function mapApiRoutes(): void { - Route::middleware('api')->prefix('api')->name('api.')->group(module_path('$MODULE$', '$API_ROUTES_PATH$')); + Route::middleware('api')->prefix('api')->name('api.')->group(module_path($this->name, '$API_ROUTES_PATH$')); } } diff --git a/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generate_module_when_provider_is_enable_and_route_provider_is_enable__2.txt b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generate_module_when_provider_is_enable_and_route_provider_is_enable__2.txt index dc17450cc..650b28386 100644 --- a/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generate_module_when_provider_is_enable_and_route_provider_is_enable__2.txt +++ b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generate_module_when_provider_is_enable_and_route_provider_is_enable__2.txt @@ -7,6 +7,8 @@ use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvi class RouteServiceProvider extends ServiceProvider { + protected string $name = 'Blog'; + /** * Called before routes are registered. * @@ -23,7 +25,6 @@ class RouteServiceProvider extends ServiceProvider public function map(): void { $this->mapApiRoutes(); - $this->mapWebRoutes(); } @@ -34,7 +35,7 @@ class RouteServiceProvider extends ServiceProvider */ protected function mapWebRoutes(): void { - Route::middleware('web')->group(module_path('Blog', '/routes/web.php')); + Route::middleware('web')->group(module_path($this->name, '/routes/web.php')); } /** @@ -44,6 +45,6 @@ class RouteServiceProvider extends ServiceProvider */ protected function mapApiRoutes(): void { - Route::middleware('api')->prefix('api')->name('api.')->group(module_path('Blog', '/routes/api.php')); + Route::middleware('api')->prefix('api')->name('api.')->group(module_path($this->name, '/routes/api.php')); } } diff --git a/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_api_module_with_resources__4.txt b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_api_module_with_resources__4.txt index dc17450cc..650b28386 100644 --- a/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_api_module_with_resources__4.txt +++ b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_api_module_with_resources__4.txt @@ -7,6 +7,8 @@ use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvi class RouteServiceProvider extends ServiceProvider { + protected string $name = 'Blog'; + /** * Called before routes are registered. * @@ -23,7 +25,6 @@ class RouteServiceProvider extends ServiceProvider public function map(): void { $this->mapApiRoutes(); - $this->mapWebRoutes(); } @@ -34,7 +35,7 @@ class RouteServiceProvider extends ServiceProvider */ protected function mapWebRoutes(): void { - Route::middleware('web')->group(module_path('Blog', '/routes/web.php')); + Route::middleware('web')->group(module_path($this->name, '/routes/web.php')); } /** @@ -44,6 +45,6 @@ class RouteServiceProvider extends ServiceProvider */ protected function mapApiRoutes(): void { - Route::middleware('api')->prefix('api')->name('api.')->group(module_path('Blog', '/routes/api.php')); + Route::middleware('api')->prefix('api')->name('api.')->group(module_path($this->name, '/routes/api.php')); } } diff --git a/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_resources__3.txt b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_resources__3.txt index dc17450cc..650b28386 100644 --- a/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_resources__3.txt +++ b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_resources__3.txt @@ -7,6 +7,8 @@ use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvi class RouteServiceProvider extends ServiceProvider { + protected string $name = 'Blog'; + /** * Called before routes are registered. * @@ -23,7 +25,6 @@ class RouteServiceProvider extends ServiceProvider public function map(): void { $this->mapApiRoutes(); - $this->mapWebRoutes(); } @@ -34,7 +35,7 @@ class RouteServiceProvider extends ServiceProvider */ protected function mapWebRoutes(): void { - Route::middleware('web')->group(module_path('Blog', '/routes/web.php')); + Route::middleware('web')->group(module_path($this->name, '/routes/web.php')); } /** @@ -44,6 +45,6 @@ class RouteServiceProvider extends ServiceProvider */ protected function mapApiRoutes(): void { - Route::middleware('api')->prefix('api')->name('api.')->group(module_path('Blog', '/routes/api.php')); + Route::middleware('api')->prefix('api')->name('api.')->group(module_path($this->name, '/routes/api.php')); } } diff --git a/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources__4.txt b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources__4.txt index dc17450cc..650b28386 100644 --- a/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources__4.txt +++ b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources__4.txt @@ -7,6 +7,8 @@ use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvi class RouteServiceProvider extends ServiceProvider { + protected string $name = 'Blog'; + /** * Called before routes are registered. * @@ -23,7 +25,6 @@ class RouteServiceProvider extends ServiceProvider public function map(): void { $this->mapApiRoutes(); - $this->mapWebRoutes(); } @@ -34,7 +35,7 @@ class RouteServiceProvider extends ServiceProvider */ protected function mapWebRoutes(): void { - Route::middleware('web')->group(module_path('Blog', '/routes/web.php')); + Route::middleware('web')->group(module_path($this->name, '/routes/web.php')); } /** @@ -44,6 +45,6 @@ class RouteServiceProvider extends ServiceProvider */ protected function mapApiRoutes(): void { - Route::middleware('api')->prefix('api')->name('api.')->group(module_path('Blog', '/routes/api.php')); + Route::middleware('api')->prefix('api')->name('api.')->group(module_path($this->name, '/routes/api.php')); } } diff --git a/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources_when_adding_more_than_one_option__4.txt b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources_when_adding_more_than_one_option__4.txt index dc17450cc..650b28386 100644 --- a/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources_when_adding_more_than_one_option__4.txt +++ b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources_when_adding_more_than_one_option__4.txt @@ -7,6 +7,8 @@ use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvi class RouteServiceProvider extends ServiceProvider { + protected string $name = 'Blog'; + /** * Called before routes are registered. * @@ -23,7 +25,6 @@ class RouteServiceProvider extends ServiceProvider public function map(): void { $this->mapApiRoutes(); - $this->mapWebRoutes(); } @@ -34,7 +35,7 @@ class RouteServiceProvider extends ServiceProvider */ protected function mapWebRoutes(): void { - Route::middleware('web')->group(module_path('Blog', '/routes/web.php')); + Route::middleware('web')->group(module_path($this->name, '/routes/web.php')); } /** @@ -44,6 +45,6 @@ class RouteServiceProvider extends ServiceProvider */ protected function mapApiRoutes(): void { - Route::middleware('api')->prefix('api')->name('api.')->group(module_path('Blog', '/routes/api.php')); + Route::middleware('api')->prefix('api')->name('api.')->group(module_path($this->name, '/routes/api.php')); } } diff --git a/tests/Commands/Make/__snapshots__/RouteProviderMakeCommandTest__test_it_can_change_the_custom_controller_namespace__1.txt b/tests/Commands/Make/__snapshots__/RouteProviderMakeCommandTest__test_it_can_change_the_custom_controller_namespace__1.txt index 79746f865..8d3b18fc2 100644 --- a/tests/Commands/Make/__snapshots__/RouteProviderMakeCommandTest__test_it_can_change_the_custom_controller_namespace__1.txt +++ b/tests/Commands/Make/__snapshots__/RouteProviderMakeCommandTest__test_it_can_change_the_custom_controller_namespace__1.txt @@ -7,6 +7,8 @@ use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvi class RouteServiceProvider extends ServiceProvider { + protected string $name = 'Blog'; + /** * Called before routes are registered. * @@ -23,7 +25,6 @@ class RouteServiceProvider extends ServiceProvider public function map(): void { $this->mapApiRoutes(); - $this->mapWebRoutes(); } @@ -34,7 +35,7 @@ class RouteServiceProvider extends ServiceProvider */ protected function mapWebRoutes(): void { - Route::middleware('web')->group(module_path('Blog', '/routes/web.php')); + Route::middleware('web')->group(module_path($this->name, '/routes/web.php')); } /** @@ -44,6 +45,6 @@ class RouteServiceProvider extends ServiceProvider */ protected function mapApiRoutes(): void { - Route::middleware('api')->prefix('api')->name('api.')->group(module_path('Blog', '/routes/api.php')); + Route::middleware('api')->prefix('api')->name('api.')->group(module_path($this->name, '/routes/api.php')); } } diff --git a/tests/Commands/Make/__snapshots__/RouteProviderMakeCommandTest__test_it_can_change_the_default_namespace__1.txt b/tests/Commands/Make/__snapshots__/RouteProviderMakeCommandTest__test_it_can_change_the_default_namespace__1.txt index af40c469e..43a25d37e 100644 --- a/tests/Commands/Make/__snapshots__/RouteProviderMakeCommandTest__test_it_can_change_the_default_namespace__1.txt +++ b/tests/Commands/Make/__snapshots__/RouteProviderMakeCommandTest__test_it_can_change_the_default_namespace__1.txt @@ -7,6 +7,8 @@ use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvi class RouteServiceProvider extends ServiceProvider { + protected string $name = 'Blog'; + /** * Called before routes are registered. * @@ -23,7 +25,6 @@ class RouteServiceProvider extends ServiceProvider public function map(): void { $this->mapApiRoutes(); - $this->mapWebRoutes(); } @@ -34,7 +35,7 @@ class RouteServiceProvider extends ServiceProvider */ protected function mapWebRoutes(): void { - Route::middleware('web')->group(module_path('Blog', '/routes/web.php')); + Route::middleware('web')->group(module_path($this->name, '/routes/web.php')); } /** @@ -44,6 +45,6 @@ class RouteServiceProvider extends ServiceProvider */ protected function mapApiRoutes(): void { - Route::middleware('api')->prefix('api')->name('api.')->group(module_path('Blog', '/routes/api.php')); + Route::middleware('api')->prefix('api')->name('api.')->group(module_path($this->name, '/routes/api.php')); } } diff --git a/tests/Commands/Make/__snapshots__/RouteProviderMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt b/tests/Commands/Make/__snapshots__/RouteProviderMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt index af40c469e..43a25d37e 100644 --- a/tests/Commands/Make/__snapshots__/RouteProviderMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt +++ b/tests/Commands/Make/__snapshots__/RouteProviderMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt @@ -7,6 +7,8 @@ use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvi class RouteServiceProvider extends ServiceProvider { + protected string $name = 'Blog'; + /** * Called before routes are registered. * @@ -23,7 +25,6 @@ class RouteServiceProvider extends ServiceProvider public function map(): void { $this->mapApiRoutes(); - $this->mapWebRoutes(); } @@ -34,7 +35,7 @@ class RouteServiceProvider extends ServiceProvider */ protected function mapWebRoutes(): void { - Route::middleware('web')->group(module_path('Blog', '/routes/web.php')); + Route::middleware('web')->group(module_path($this->name, '/routes/web.php')); } /** @@ -44,6 +45,6 @@ class RouteServiceProvider extends ServiceProvider */ protected function mapApiRoutes(): void { - Route::middleware('api')->prefix('api')->name('api.')->group(module_path('Blog', '/routes/api.php')); + Route::middleware('api')->prefix('api')->name('api.')->group(module_path($this->name, '/routes/api.php')); } } diff --git a/tests/Commands/Make/__snapshots__/RouteProviderMakeCommandTest__test_it_can_overwrite_file__1.txt b/tests/Commands/Make/__snapshots__/RouteProviderMakeCommandTest__test_it_can_overwrite_file__1.txt index e8d7205d7..9b80aa3d4 100644 --- a/tests/Commands/Make/__snapshots__/RouteProviderMakeCommandTest__test_it_can_overwrite_file__1.txt +++ b/tests/Commands/Make/__snapshots__/RouteProviderMakeCommandTest__test_it_can_overwrite_file__1.txt @@ -7,6 +7,8 @@ use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvi class RouteServiceProvider extends ServiceProvider { + protected string $name = 'Blog'; + /** * Called before routes are registered. * @@ -23,7 +25,6 @@ class RouteServiceProvider extends ServiceProvider public function map(): void { $this->mapApiRoutes(); - $this->mapWebRoutes(); } @@ -34,7 +35,7 @@ class RouteServiceProvider extends ServiceProvider */ protected function mapWebRoutes(): void { - Route::middleware('web')->group(module_path('Blog', '/SuperRoutes/web.php')); + Route::middleware('web')->group(module_path($this->name, '/SuperRoutes/web.php')); } /** @@ -44,6 +45,6 @@ class RouteServiceProvider extends ServiceProvider */ protected function mapApiRoutes(): void { - Route::middleware('api')->prefix('api')->name('api.')->group(module_path('Blog', '/routes/api.php')); + Route::middleware('api')->prefix('api')->name('api.')->group(module_path($this->name, '/routes/api.php')); } } diff --git a/tests/Commands/Make/__snapshots__/RouteProviderMakeCommandTest__test_it_can_overwrite_route_file_names__1.txt b/tests/Commands/Make/__snapshots__/RouteProviderMakeCommandTest__test_it_can_overwrite_route_file_names__1.txt index 7c40e3d35..fe4cb9a89 100644 --- a/tests/Commands/Make/__snapshots__/RouteProviderMakeCommandTest__test_it_can_overwrite_route_file_names__1.txt +++ b/tests/Commands/Make/__snapshots__/RouteProviderMakeCommandTest__test_it_can_overwrite_route_file_names__1.txt @@ -7,6 +7,8 @@ use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvi class RouteServiceProvider extends ServiceProvider { + protected string $name = 'Blog'; + /** * Called before routes are registered. * @@ -23,7 +25,6 @@ class RouteServiceProvider extends ServiceProvider public function map(): void { $this->mapApiRoutes(); - $this->mapWebRoutes(); } @@ -34,7 +35,7 @@ class RouteServiceProvider extends ServiceProvider */ protected function mapWebRoutes(): void { - Route::middleware('web')->group(module_path('Blog', '/SuperRoutes/web.php')); + Route::middleware('web')->group(module_path($this->name, '/SuperRoutes/web.php')); } /** @@ -44,6 +45,6 @@ class RouteServiceProvider extends ServiceProvider */ protected function mapApiRoutes(): void { - Route::middleware('api')->prefix('api')->name('api.')->group(module_path('Blog', '/SuperRoutes/api.php')); + Route::middleware('api')->prefix('api')->name('api.')->group(module_path($this->name, '/SuperRoutes/api.php')); } } diff --git a/tests/Commands/Make/__snapshots__/RouteProviderMakeCommandTest__test_it_generated_correct_file_with_content__1.txt b/tests/Commands/Make/__snapshots__/RouteProviderMakeCommandTest__test_it_generated_correct_file_with_content__1.txt index dc17450cc..650b28386 100644 --- a/tests/Commands/Make/__snapshots__/RouteProviderMakeCommandTest__test_it_generated_correct_file_with_content__1.txt +++ b/tests/Commands/Make/__snapshots__/RouteProviderMakeCommandTest__test_it_generated_correct_file_with_content__1.txt @@ -7,6 +7,8 @@ use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvi class RouteServiceProvider extends ServiceProvider { + protected string $name = 'Blog'; + /** * Called before routes are registered. * @@ -23,7 +25,6 @@ class RouteServiceProvider extends ServiceProvider public function map(): void { $this->mapApiRoutes(); - $this->mapWebRoutes(); } @@ -34,7 +35,7 @@ class RouteServiceProvider extends ServiceProvider */ protected function mapWebRoutes(): void { - Route::middleware('web')->group(module_path('Blog', '/routes/web.php')); + Route::middleware('web')->group(module_path($this->name, '/routes/web.php')); } /** @@ -44,6 +45,6 @@ class RouteServiceProvider extends ServiceProvider */ protected function mapApiRoutes(): void { - Route::middleware('api')->prefix('api')->name('api.')->group(module_path('Blog', '/routes/api.php')); + Route::middleware('api')->prefix('api')->name('api.')->group(module_path($this->name, '/routes/api.php')); } }