Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

zaedfsh's avatar

Filament Shield for resources

I've successfully installed Filament Shield, and setup supser_admin and panel_user roles. The Filament Shield menu items shows and hides when logged in with users of different roles respectively.

Then I installed tomatophp/filament-users, which utilizes the native user model at app/Models/User.php while provides its own user resource. The Users menu item always shows no matter which user is logged in.

How to make the user resource act as the Filament Role? i.e. the Users menu item shows to users of super_admin and hides for other users?

Enviorment Info

Laravel version: 10.38.2
Filament version: 3.1.29
Shield version: 3.1.2
0 likes
7 replies
aisuvro's avatar

Hi,

Make a policy for users.

php artisan make:policy UserPolicy --model=User

Register the policy in the \App\Providers\AuthServiceProvider.

    protected $policies = [
        \App\Models\User::class => \App\Policies\UserPolicy::class,
    ];

In the UserPolicy page write your logic in the view all method. The policy will be magically applied to the user resource.

I hope you get the idea. Cheers

zaedfsh's avatar

@aisuvro Thanks! It does work!

However, I believe that php artisan make:policy is a Laravel command, and I have to write the same logics for more models manually. Is there a way to simplify it via Filament Shield?

I tried php artisan shield:generate --resource=user. It prompted some success message, but nothing really happened.

    INFO  Successfully generated Permissions & Policies for:  

+---+----------+--------+-------------+
| # | Resource | Policy | Permissions |
+---+----------+--------+-------------+

   INFO  Permission & Policies are generated according to your config or passed options.  

   INFO  Enjoy!  
masepri's avatar

Hi @zaedfsh

go to config/filament-shield.php

change

 'discover_all_resources' => false

to

 'discover_all_resources' => true

Hope it helps

orestebh90's avatar

@zaedfsh Try php artisan shield:generate --resource=UserResource You have to put the name of the resource, as is the file name.

3 likes
alinko's avatar

Hello , i found same issues. and i change config/filament-shield.php

'register_role_policy' => [
        'enabled' => false,
    ],

to

register_role_policy' => [
        'enabled' => true,
    ],

It's work for me

Please or to participate in this conversation.