Please add canSeeWhenAny(["...", "..."]) to ProxiesCanSeeToGate #5310
Unanswered
puzzledmonkey
asked this question in
Q&A
Replies: 1 comment 1 reply
-
You can add macros to Field::macro('canSeeWhenAny', function () {
// ....
}); |
Beta Was this translation helpful? Give feedback.
1 reply
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.
-
ProxiesCanSeeToGate allows us to use Field::make(...)->canSeeWhen('permission'); and it can also be used with arrays (even though the jsdoc says it should be a string only - Illuminate\Foundation\Auth\Access\Authorizable allows iterable|string for the first parameter).
This greatly cuts down the amount of boilerplate code required to do ->canSee(function($request) { return $request->user()->can(...); }) and is really useful.
Would it be possible to add another method - canSeeWhenAny(["...", "..."]) which just proxies to user()->canAny(...) instead of user()->can(...)? That will help in cases where multiple access permissions could allow access to the same card, dashboard, etc etc.
Thanks for considering! :)
Beta Was this translation helpful? Give feedback.
All reactions