Silvanite / novatoolpermissions

Laravel Nova Permissions Tool (User, Roles and Permissions / Access Control (ACL))
MIT License
101 stars 33 forks source link

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

Open leo-unglaub opened 5 years ago

leo-unglaub commented 5 years ago

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 commented 4 years ago

@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