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:
Svetlin Stoev 2021-11-27 20:35:22 +02:00 committed by GitHub
parent ddfc912ad3
commit 196ebaa5b6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -30,6 +30,13 @@ Then add this to your `AppServiceProvider::boot()` method:
```php
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;
});
```