mercredi 25 janvier 2017

Policies, when should you use authorize rather than can/cannot and vise-versa

I am writing a policy in laravel to make sure a user owns a post or is an admin, now in the docs it states:

The authorize method shares the same signature as the various other authorization methods such as Gate::allows and $user->can(). So, let's use the authorize method to quickly authorize a request to update a Post:

To my understanding, can/cannot is the same as authorize being that is throws an exception, now when should you use one than the other?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire