Update spatie.blade.md

$cacheKey has become static
This commit is contained in:
Bram Wubs 2024-02-28 09:01:56 +01:00 committed by GitHub
parent d6233d0df2
commit 06ab596048
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -34,15 +34,13 @@ Next, add the following listeners to the `TenancyBootstrapped` and `TenancyEnde
```php ```php
Events\TenancyBootstrapped::class => [ Events\TenancyBootstrapped::class => [
function (Events\TenancyBootstrapped $event) { function (Events\TenancyBootstrapped $event) {
$permissionRegistrar = app(\Spatie\Permission\PermissionRegistrar::class); \Spatie\Permission\PermissionRegistrar::$cacheKey = 'spatie.permission.cache.tenant.' . $event->tenancy->tenant->getTenantKey();
$permissionRegistrar->cacheKey = 'spatie.permission.cache.tenant.' . $event->tenancy->tenant->getTenantKey();
} }
], ],
Events\TenancyEnded::class => [ Events\TenancyEnded::class => [
function (Events\TenancyEnded $event) { function (Events\TenancyEnded $event) {
$permissionRegistrar = app(\Spatie\Permission\PermissionRegistrar::class); \Spatie\Permission\PermissionRegistrar::$cacheKey = 'spatie.permission.cache';
$permissionRegistrar->cacheKey = 'spatie.permission.cache';
} }
], ],
``` ```
@ -52,18 +50,14 @@ Alternatively, create a bootstrapper:
```php ```php
class SpatiePermissionsBootstrapper implements TenancyBootstrapper class SpatiePermissionsBootstrapper implements TenancyBootstrapper
{ {
public function __construct(
protected PermissionRegistrar $registrar,
) {}
public function bootstrap(Tenant $tenant): void public function bootstrap(Tenant $tenant): void
{ {
$this->registrar->cacheKey = 'spatie.permission.cache.tenant.' . $tenant->getTenantKey(); \Spatie\Permission\PermissionRegistrar::$cacheKey = 'spatie.permission.cache.tenant.' . $tenant->getTenantKey();
} }
public function revert(): void public function revert(): void
{ {
$this->registrar->cacheKey = 'spatie.permission.cache'; \Spatie\Permission\PermissionRegistrar::$cacheKey = 'spatie.permission.cache';
} }
} }
``` ```