Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible wrong signature of Gate::any() #51

Open
leo-unglaub opened this issue Oct 7, 2019 · 1 comment
Open

Possible wrong signature of Gate::any() #51

leo-unglaub opened this issue Oct 7, 2019 · 1 comment

Comments

@leo-unglaub
Copy link

Hey,
i am looking thru your documentation and i found this here:

public function view($user, $post)
{
    return Gate::any(['viewBlog', 'manageBlog'], $user, $post);
}

But i cannot find an implementation of Gate::any with that signature (with three params). Are you sure this is intended? Or did you mean:

public function view($user, $post)
{
    return Gate::any(['viewBlog', 'manageBlog'], [$user, $post]);
}

Thanks and greetings
Leo

@andrzejkupczyk
Copy link

andrzejkupczyk commented Jul 24, 2020

@leo-unglaub , you're correct. Provided example as well as default policies implementations are misleading.
On the other hand $user is passed to the callback anyway, so providing $post would be sufficient in this case (but still not required):

public function view($user, $post)
{
    return Gate::any(['viewBlog', 'manageBlog'], $post);
}

https://laravel.com/docs/7.x/authorization#writing-gates

Gates always receive a user instance as their first argument, and may optionally receive additional arguments such as a relevant Eloquent model

yayann added a commit to SGS-Optimisation/novatoolpermissions that referenced this issue Jan 23, 2023
added mysgs integrations api endpoint
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants