Role restrict Resources

I have two resources that use the same model. The problem is that according to docs For authorization, Filament will observe any model policies that are registered in your app. and I am not able to hide menu entries in Navigation like:
->navigationGroups([
NavigationGroup::make()
->label('Onlycatadmins'),
NavigationGroup::make()
->label('Onlydogadmins'),
])
->navigationGroups([
NavigationGroup::make()
->label('Onlycatadmins'),
NavigationGroup::make()
->label('Onlydogadmins'),
])
Think an admin with a specific resource for query results limited for animal_id = cat if it is a cat administratior and a specific resource for animal_id = dog and only dog admins will see dogs resource in the navigation menu. But it will be the same model Animal and table animals.
1 Reply
Saade
Saade4mo ago
You can override any of the methods Filament uses to check policies https://github.com/filamentphp/filament/blob/f26e35ee750c461f26f898bd97b75bf0e3b448ac/packages/panels/src/Resources/Resource.php#L248 But you can override the shouldRegisterNavigation method, which controls if the NavigationItem should be registered https://github.com/filamentphp/filament/blob/f26e35ee750c461f26f898bd97b75bf0e3b448ac/packages/panels/src/Resources/Resource.php#L860