© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3y ago•
13 replies
Geoff.

multitenacy combined with tenancyforlaravel and filament shield permission problem

Hello all,

I have a a problem with the permissions of filament shield. When i run the shield:generate on the admin app all is working for the admin. But then when I run the shield:generate for the tenant (different database) with tenants:run … the permissions are ok for the tenant but not anymore for the admin.

I think it has something todo with the caching of the permissions.

So two quesions:

Is there a way to disable the caching of the permission for testing purpose?

Is there a way to cache the permissions for a panel?


I hope someone knows the answer 😬

Thanks already
Solution
1. To disable cache in dev mode set the
CACHE_DRIVER=array
CACHE_DRIVER=array
in .env file or set the cache store to array from permission config file. learn more https://spatie.be/docs/laravel-permission/v5/advanced-usage/cache
2. since you are using that package you need to add the following in
TenancyServiceProvider
TenancyServiceProvider

Events\TenancyBootstrapped::class => [
    function (Events\TenancyBootstrapped $event) {
        \Spatie\Permission\PermissionRegistrar::$cacheKey = 'spatie.permission.cache.tenant.' . $event->tenancy->tenant->id;
    }
],

Events\TenancyEnded::class => [
    function (Events\TenancyEnded $event) {
        \Spatie\Permission\PermissionRegistrar::$cacheKey = 'spatie.permission.cache';
    }
],
Events\TenancyBootstrapped::class => [
    function (Events\TenancyBootstrapped $event) {
        \Spatie\Permission\PermissionRegistrar::$cacheKey = 'spatie.permission.cache.tenant.' . $event->tenancy->tenant->id;
    }
],

Events\TenancyEnded::class => [
    function (Events\TenancyEnded $event) {
        \Spatie\Permission\PermissionRegistrar::$cacheKey = 'spatie.permission.cache';
    }
],

learn more https://tenancyforlaravel.com/docs/v3/integrations/spatie
Jump to solution
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

Filament shield - Permission management
FilamentFFilament / ❓┊help
14mo ago
Custom permission use filament shield
FilamentFFilament / ❓┊help
4mo ago
Is Filament V3 with compatible with tenancyforlaravel https://tenancyforlaravel.com/
FilamentFFilament / ❓┊help
3y ago
Do we need Spatie Permission with Filament Shield?
FilamentFFilament / ❓┊help
2y ago