diff --git a/assets/tenant_routes.php.stub b/assets/tenant_routes.stub.php similarity index 68% rename from assets/tenant_routes.php.stub rename to assets/tenant_routes.stub.php index 4e501123..d66a8dc5 100644 --- a/assets/tenant_routes.php.stub +++ b/assets/tenant_routes.stub.php @@ -1,6 +1,8 @@ ['web', InitializeTenancyByDomain::class], + 'middleware' => ['web', PreventAccessFromCentralDomains::class, InitializeTenancyByDomain::class], 'prefix' => '/app', ], function () { Route::get('/', function () { diff --git a/src/Commands/Install.php b/src/Commands/Install.php index b50466d5..dd2dd280 100644 --- a/src/Commands/Install.php +++ b/src/Commands/Install.php @@ -37,7 +37,10 @@ class Install extends Command $this->info('✔️ Created config/tenancy.php'); if (! file_exists(base_path('routes/tenant.php'))) { - file_put_contents(base_path('routes/tenant.php'), file_get_contents(__DIR__ . '/../../assets/tenant_routes.php.stub')); + $this->callSilent('vendor:publish', [ + '--provider' => 'Stancl\Tenancy\TenancyServiceProvider', + '--tag' => 'routes', + ]); $this->info('✔️ Created routes/tenant.php'); } else { $this->info('Found routes/tenant.php.'); diff --git a/src/TenancyServiceProvider.php b/src/TenancyServiceProvider.php index 5cac36c6..a8d39021 100644 --- a/src/TenancyServiceProvider.php +++ b/src/TenancyServiceProvider.php @@ -91,6 +91,10 @@ class TenancyServiceProvider extends ServiceProvider __DIR__ . '/../assets/impersonation-migrations/' => database_path('migrations'), ], 'impersonation-migrations'); + $this->publishes([ + __DIR__ . '/../assets/tenant_routes.stub.php' => config_path('tenancy.php'), + ], 'routes'); + $this->publishes([ __DIR__ . '/../assets/TenancyServiceProvider.stub.php' => app_path('Providers/TenancyServiceProvider.php'), ], 'providers');