Small code change to allow fallback/default policies #6321
Replies: 1 comment
-
Released with Laravel Nova 5.0.0 Feel free to open up a new issue if you're still experiencing this problem on the latest version. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I've been trying to implement default policies and noticed that Nova handles policies slightly different to the Laravel framework. In the policy checks in Laravel, they use
is_callable
to check if a policy class has a method. Nova usesmethod_exists
which doesn't allow the__call
method to be used in a policy class.In order to allow for things like fallback or default policies, Nova would need to replace the
method_exists
calls in Authorizable.php withis_callable
. I tested this out locally and it seems to work without any issues (so far). Here is the regex for replacing if you are curious: replace allmethod_exists\(\$gate, (.+?)\)
tois_callable([$gate, $1])
in the Authorizable trait in Nova.Let me know if you have any questions. Thanks for your time in considering this change.
Related issue: #1147
Beta Was this translation helpful? Give feedback.
All reactions