mirror of
https://github.com/stancl/tenancy-docs.git
synced 2025-12-12 18:24:03 +00:00
Update spatie.blade.md (#144)
* 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. * Add instruction to reset cache key on TenancyEnded Co-authored-by: lukinovec <lukinovec@gmail.com>
This commit is contained in:
parent
af05970907
commit
58cd62fab0
1 changed files with 5 additions and 1 deletions
|
|
@ -29,12 +29,16 @@ php artisan vendor:publish --provider="Spatie\Permission\PermissionServiceProvid
|
|||
mv database/migrations/*_create_permission_tables.php database/migrations/tenant
|
||||
```
|
||||
|
||||
Then add this to your `AppServiceProvider::boot()` method:
|
||||
Then add this to your `TenancyServiceProvider::boot()`:
|
||||
|
||||
```php
|
||||
Event::listen(TenancyBootstrapped::class, function (TenancyBootstrapped $event) {
|
||||
\Spatie\Permission\PermissionRegistrar::$cacheKey = 'spatie.permission.cache.tenant.' . $event->tenancy->tenant->id;
|
||||
});
|
||||
|
||||
Event::listen(TenancyEnded::class, function (TenancyEnded $event) {
|
||||
\Spatie\Permission\PermissionRegistrar::$cacheKey = 'spatie.permission.cache';
|
||||
});
|
||||
```
|
||||
|
||||
The reason for this is that spatie/laravel-permission caches permissions & roles to save DB queries, which means that we need to separate the permission cache by tenant.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue