You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Sorry, my English not good. Please update this post if you understand my problem.
Problem
Currently, Laravel support multi auth (multi
Authenticatable
) like:And Laravel support generate Policy class for special user model with option
--grard
.But only one Policy class can load by default.
Current solution
I have two solutions
Solution 1:
Using
Gate::guessPolicyNamesUsing()
methodSolution 2:
Using magic method and forward to special Policy class
Create classes
And Laravel will load Policy classes automatic.
Suggestion for Laravel
Add
$user
parameter toGate::getPolicyFor()
,Gate::guessPolicyName()
method andguessPolicyNamesUsingCallback
callback.https://github.com/laravel/framework/blob/9.x/src/Illuminate/Auth/Access/Gate.php#L613
https://github.com/laravel/framework/blob/9.x/src/Illuminate/Auth/Access/Gate.php#L642
https://github.com/laravel/framework/blob/9.x/src/Illuminate/Auth/Access/Gate.php#L675
https://github.com/laravel/framework/blob/9.x/src/Illuminate/Auth/Access/Gate.php#L678
When that, simple solution like solution 1.
Beta Was this translation helpful? Give feedback.
All reactions