mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-12 12:54:05 +00:00
Add identification section to config, refactor static properties
This commit is contained in:
parent
e5bc8ddb77
commit
ccaba05272
17 changed files with 153 additions and 97 deletions
|
|
@ -144,16 +144,8 @@ class TenancyServiceProvider extends ServiceProvider
|
|||
|
||||
protected function makeTenancyMiddlewareHighestPriority()
|
||||
{
|
||||
$tenancyMiddleware = [
|
||||
// Even higher priority than the initialization middleware
|
||||
Middleware\PreventAccessFromCentralDomains::class,
|
||||
|
||||
Middleware\InitializeTenancyByDomain::class,
|
||||
Middleware\InitializeTenancyBySubdomain::class,
|
||||
Middleware\InitializeTenancyByDomainOrSubdomain::class,
|
||||
Middleware\InitializeTenancyByPath::class,
|
||||
Middleware\InitializeTenancyByRequestData::class,
|
||||
];
|
||||
// Even higher priority than the initialization middleware
|
||||
$tenancyMiddleware = array_merge([Middleware\PreventAccessFromCentralDomains::class], config('tenancy.identification.middleware'));
|
||||
|
||||
foreach (array_reverse($tenancyMiddleware) as $middleware) {
|
||||
$this->app[\Illuminate\Contracts\Http\Kernel::class]->prependToMiddlewarePriority($middleware);
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@ declare(strict_types=1);
|
|||
|
||||
use Stancl\Tenancy\Database\Models\Domain;
|
||||
use Stancl\Tenancy\Database\Models\Tenant;
|
||||
use Stancl\Tenancy\Middleware;
|
||||
use Stancl\Tenancy\Resolvers;
|
||||
|
||||
return [
|
||||
'tenant_model' => Tenant::class,
|
||||
|
|
@ -21,6 +23,56 @@ return [
|
|||
'localhost',
|
||||
],
|
||||
|
||||
'identification' => [
|
||||
/**
|
||||
* The default middleware used for tenant identification.
|
||||
*
|
||||
* If you use multiple forms of identification, you can set this to the "main" approach you use.
|
||||
*/
|
||||
'default_middleware' => Middleware\InitializeTenancyByDomain::class,// todo@identification add this to a 'tenancy' mw group
|
||||
|
||||
/**
|
||||
* All of the identification middleware used by the package.
|
||||
*
|
||||
* If you write your own, make sure to add them to this array.
|
||||
*/
|
||||
'middleware' => [
|
||||
Middleware\InitializeTenancyByDomain::class,
|
||||
Middleware\InitializeTenancyBySubdomain::class,
|
||||
Middleware\InitializeTenancyByDomainOrSubdomain::class,
|
||||
Middleware\InitializeTenancyByPath::class,
|
||||
Middleware\InitializeTenancyByRequestData::class,
|
||||
],
|
||||
|
||||
/**
|
||||
* Tenant resolvers used by the package.
|
||||
*
|
||||
* Resolvers which implement the CachedTenantResolver contract have options for configuring the caching details.
|
||||
* If you add your own resolvers, do not add the 'cache' key unless your resolver is based on CachedTenantResolver.
|
||||
*/
|
||||
'resolvers' => [
|
||||
Resolvers\DomainTenantResolver::class => [
|
||||
'cache' => false,
|
||||
'cache_ttl' => 3600, // seconds
|
||||
'cache_store' => null, // default
|
||||
],
|
||||
Resolvers\PathTenantResolver::class => [
|
||||
'tenant_parameter_name' => 'tenant',
|
||||
|
||||
'cache' => false,
|
||||
'cache_ttl' => 3600, // seconds
|
||||
'cache_store' => null, // default
|
||||
],
|
||||
Resolvers\RequestDataTenantResolver::class => [
|
||||
'cache' => false,
|
||||
'cache_ttl' => 3600, // seconds
|
||||
'cache_store' => null, // default
|
||||
],
|
||||
],
|
||||
|
||||
// todo@docs update integration guides to use Stancl\Tenancy::defaultMiddleware()
|
||||
],
|
||||
|
||||
/**
|
||||
* Tenancy bootstrappers are executed when tenancy is initialized.
|
||||
* Their responsibility is making Laravel features tenant-aware.
|
||||
|
|
|
|||
|
|
@ -3,7 +3,8 @@
|
|||
declare(strict_types=1);
|
||||
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Stancl\Tenancy\Controllers\TenantAssetController;
|
||||
|
||||
Route::get('/tenancy/assets/{path?}', 'Stancl\Tenancy\Controllers\TenantAssetsController@asset')
|
||||
Route::get('/tenancy/assets/{path?}', [TenantAssetController::class, 'asset'])
|
||||
->where('path', '(.*)')
|
||||
->name('stancl.tenancy.asset');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue