mirror of
https://github.com/stancl/tenancy-docs.git
synced 2025-12-12 10:14:03 +00:00
Update spatie.blade.md
When a tenant is created through the central app TenancyBootstraped is called and wrong permissions are cached if permissions between central and tenant apps are different.
This commit is contained in:
parent
ddfc912ad3
commit
196ebaa5b6
1 changed files with 7 additions and 0 deletions
|
|
@ -30,6 +30,13 @@ Then add this to your `AppServiceProvider::boot()` method:
|
||||||
|
|
||||||
```php
|
```php
|
||||||
Event::listen(TenancyBootstrapped::class, function (TenancyBootstrapped $event) {
|
Event::listen(TenancyBootstrapped::class, function (TenancyBootstrapped $event) {
|
||||||
|
// TenancyBootstraped event is called if you are creating tenants through the central app,
|
||||||
|
// so to prevent making caches with wrong permissions the code below can be used
|
||||||
|
//
|
||||||
|
// $isACentralDomain = in_array(request()->getHost(), config('tenancy.central_domains'), true);
|
||||||
|
// if(!$isACentralDomain) {
|
||||||
|
// \Spatie\Permission\PermissionRegistrar::$cacheKey = 'spatie.permission.cache.tenant.' . $event->tenancy->tenant->id;
|
||||||
|
// }
|
||||||
\Spatie\Permission\PermissionRegistrar::$cacheKey = 'spatie.permission.cache.tenant.' . $event->tenancy->tenant->id;
|
\Spatie\Permission\PermissionRegistrar::$cacheKey = 'spatie.permission.cache.tenant.' . $event->tenancy->tenant->id;
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue