Use variadic functions when authorizing actions with additional context #54341
Unanswered
ethanransdellverse
asked this question in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Laravel is often flexible when calling methods by allowing arrays or an undefined number of variables. This is even present in Auth middleware.
I thought we could support that pattern when supplying additional context for an authorization check:
The innerworkings of
can($abilities, ...$arguments)
wouldn't need to change, as$arguments
would automatically come through as an array, but unfortunately it would be a breaking change for anyone that implements theAuthorizable
interface.Example:
Beta Was this translation helpful? Give feedback.
All reactions