Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

mrafi's avatar
Level 3

what the diffrence between policy and gates ?

i am confused in policy and gate which way is prefect for authrization

0 likes
2 replies
andreigirnet96's avatar

-Policies are classes that define the authorization logic for a particular model or resource in your application.

-Gates are more generic and can be used to define custom authorization checks that are not necessarily tied to specific models.

1 like
puklipo's avatar

Gate

Closure-based routes.

Simple role system.

    Gate::define('admin', function (User $user) {
        return $user->is_admin;
    });

If you are not using it with a model, select Gate.

Policy

Controller. Use with Eloquent models.

Please or to participate in this conversation.