Confusion about Gates and Policies

Published 3 months ago by Shivafeb17

Hi, everyone,

I'm confused and not sure about Gates and Policies. Please answer the following questions, that could help me clear my doubts.

  1. Should I use Policies only when I need to apply condition to entire Model?
  2. While using Policies, it is mandatory to use Gates or can we create policies without using gates?
  3. Where can I find tutorial that explain ACL using only laravel?
jlrdw
jlrdw
3 months ago (238,490 XP)

You should perhaps:

  • Work the examples from docs
  • Watch Jeffrey's videos on Authorization and Authentication

Yes basically a policy is for example

  • An admin can do this and that
  • A user can do only that, not this

The gate works with the policy, like:

  • No user allowed beyond me, but admin is okay.
  • Or, you can not pass me unless the policy allows it.

Just a simplified explanation. An yes it can be over whelming at first.

Remember however simple auth is also there without having to mess with the gates and policies. I view gates and policies for larger complex sites with many roles and permissions.

And https://laracasts.com/lessons/users-and-roles

Please sign in or create an account to participate in this conversation.