From 196ebaa5b63c19ca0302aba6dd000001a47a460c Mon Sep 17 00:00:00 2001 From: Svetlin Stoev Date: Sat, 27 Nov 2021 20:35:22 +0200 Subject: [PATCH] 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. --- source/docs/v3/integrations/spatie.blade.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/source/docs/v3/integrations/spatie.blade.md b/source/docs/v3/integrations/spatie.blade.md index 2381e13..53be3bc 100644 --- a/source/docs/v3/integrations/spatie.blade.md +++ b/source/docs/v3/integrations/spatie.blade.md @@ -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; }); ```