same model policy: multiple resources
basically im using the same model in multiple resources, issue i have when using policies is that i can't find a way to get the resource is trying to access the policy to apply the correct filter...
i'm talking something like this: https://github.com/filamentphp/filament/discussions/7928#discussioncomment-6773578
8 Replies
i think im using the
authorizeAccess
for now ☑️anyways, I think a centralized policy for all scenarios would be more effective than using
authorizeAccess
everywhereHow to you set in the policy? Do you call User only or with Model that u using?
You can extend the policy to create new policies. That's what I do when I've to use polymorphism. Allows me to customize the policy for specific cases.
Can you show example in your policy file?
no no, Im using that method directly in the resource page not in policy
btw I'm not using Policies anymore 😶🌫️
i see
but can you show me how to do set in authorizeAccess ?
because im also using multiple resource for 1 model . having an issue to set policy on them
I think this question was for me. Here is a sample:
and then,
Here
AccountPolicy
has inherited all the methods from ModelPolicy
with appropriate customizations through static variables. And custom policy method or overrides are specified in the derived policy, such as setOpeningBalance
in this case.