0PricingLogin
PHP Academy · Lesson

Gates: Simple Authorization Checks

Define and evaluate gates for user-action permission logic.

What Are Gates?

Laravel Gates are closures that determine if a user is authorised to perform a given action. They are simple, global authorization checks not tied to a specific model.

Defining a Gate

Define gates in App\Providers\AppServiceProvider or a dedicated AuthServiceProvider using the Gate facade.

<?php
use Illuminate\Support\Facades\Gate;

// In a service provider's boot() method:
Gate::define("delete-post", function (User $user, Post $post) {
    return $user->id === $post->user_id;
});

All lessons in this course

  1. Authentication with Laravel Breeze
  2. Protecting Routes with Middleware
  3. Gates: Simple Authorization Checks
  4. Policies: Model-Based Authorization
← Back to PHP Academy