Specify which policy to use for a resource

I have multiple panels and an api. I would like to use differen policies for each part of the app. I want to prevent having 3 sides of logic in 1 policy class. Surely this should be possible?
2 Replies
Patrick Boivin
Patrick Boivin16mo ago
I'm not sure if this is a viable option but someting you can try: If you keep your custom policies outside of app/Policies, they shouldn't be automatically discovered. Then, in each panel provider, you could manually register the relevant policies via Gate::policy($model, $policy); https://laravel.com/docs/10.x/authorization#registering-policies
DanielvdSpoel
DanielvdSpoelOP16mo ago
That might work! thanks!
Want results from more Discord servers?
Add your server