Laravel theorytheory 0/50 · 0%
Auth · medium

28. Authorization: Gates & Policies

Controlling access to actions.

Gates are simple closures defining whether a user can perform an action (Gate::define('edit-post', ...)), useful for actions not tied to a specific model. Policies are classes organizing authorization logic per model, with methods like view, update, and delete, and are checked via $this->authorize() or @can in Blade. Policies are auto-discovered or registered in a service provider.

Check your understanding

  1. 1. When should you prefer a Policy over a Gate?

  2. 2. Which Blade directive checks authorization?