1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2025-12-12 17:24:03 +00:00

Map tenant routes using the SP - fix #10

This commit is contained in:
Samuel Štancl 2019-01-26 12:59:19 +01:00
parent aabe48b54a
commit 394f792ec9
3 changed files with 26 additions and 0 deletions

View file

@ -40,6 +40,8 @@ class TenancyServiceProvider extends ServiceProvider
Route::middlewareGroup('tenancy', [ Route::middlewareGroup('tenancy', [
\Stancl\Tenancy\Middleware\InitializeTenancy::class \Stancl\Tenancy\Middleware\InitializeTenancy::class
]); ]);
$this->app->register(TenantRouteServiceProvider::class);
} }
/** /**

View file

@ -0,0 +1,23 @@
<?php
namespace Stancl\Tenancy;
use Illuminate\Support\Facades\Route;
use Illuminate\Foundation\Support\Providers\RouteServiceProvider;
class TenantRouteServiceProvider extends RouteServiceProvider
{
public function map()
{
$this->mapTenantRoutes();
}
protected function mapTenantRoutes()
{
if (! in_array(request()->getHost(), $this->app['config']['tenancy.exempt_domains'] ?? [])) {
Route::middleware(['web', 'tenancy'])
->namespace($this->app['config']['tenant_route_namespace'] ?? 'App\Http\Controllers')
->group(base_path('routes/tenant.php'));
}
}
}

View file

@ -2,6 +2,7 @@
return [ return [
'storage_driver' => 'Stancl\Tenancy\StorageDrivers\RedisStorageDriver', 'storage_driver' => 'Stancl\Tenancy\StorageDrivers\RedisStorageDriver',
'tenant_route_namespace' => 'App\Http\Controllers',
'exempt_domains' => [ 'exempt_domains' => [
// 'localhost', // 'localhost',
], ],