diff --git a/README.md b/README.md index 5c6fc06b..713dcacb 100644 --- a/README.md +++ b/README.md @@ -71,10 +71,13 @@ protected function mapTenantRoutes() } ``` -And add this line to `map()`: +And add this to `map()`: ```php -$this->mapTenantRoutes(); +// Map tenant routes only if the current domain is not [exempt from tenancy](#exempt-domains). +if (! in_array(request()->getHost(), config('tenancy.exempt_domains', []))) { + $this->mapTenantRoutes(); +} ``` Now rename the `routes/web.php` file to `routes/tenant.php`. This file will contain routes accessible only with tenancy. @@ -89,6 +92,12 @@ php artisan vendor:publish --provider='Stancl\Tenancy\TenancyServiceProvider' -- You should see something along the lines of `Copied File [...] to [/config/tenancy.php]`. +#### `exempt_domains` + +Domains listed in this array won't have tenant routes. + +For example, you can put the domain on which you have your landing page here. + #### `database` Databases will be named like this: diff --git a/src/Middleware/InitializeTenancy.php b/src/Middleware/InitializeTenancy.php index 6dac54b8..cd6383a5 100644 --- a/src/Middleware/InitializeTenancy.php +++ b/src/Middleware/InitializeTenancy.php @@ -22,10 +22,6 @@ class InitializeTenancy */ public function handle($request, Closure $next) { - if (in_array($request->getHost(), config('tenancy.exempt_domains', []))) { - return $next($request); - } - try { tenancy()->init(); } catch (\Exception $e) {