what the diffrence between policy and gates ?
i am confused in policy and gate which way is prefect for authrization
-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.
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.