mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-12 20:14:03 +00:00
Map tenant routes using the SP - fix #10
This commit is contained in:
parent
aabe48b54a
commit
394f792ec9
3 changed files with 26 additions and 0 deletions
|
|
@ -40,6 +40,8 @@ class TenancyServiceProvider extends ServiceProvider
|
|||
Route::middlewareGroup('tenancy', [
|
||||
\Stancl\Tenancy\Middleware\InitializeTenancy::class
|
||||
]);
|
||||
|
||||
$this->app->register(TenantRouteServiceProvider::class);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
23
src/TenantRouteServiceProvider.php
Normal file
23
src/TenantRouteServiceProvider.php
Normal 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'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
return [
|
||||
'storage_driver' => 'Stancl\Tenancy\StorageDrivers\RedisStorageDriver',
|
||||
'tenant_route_namespace' => 'App\Http\Controllers',
|
||||
'exempt_domains' => [
|
||||
// 'localhost',
|
||||
],
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue