hi thank you for the answer ,what i want is to make access control even for the permissions model and roles model where admin user can do every thing and manger can do spacific things in the admin panel
Spatie Permissions + Laravel Policies: Best Practice for Permission/Role Controllers?
I'm building an admin panel using Spatie Laravel Permission and I'm confused about the "right way" to handle authorization in Permission/Role controllers.
Option A (Direct Spatie check):
if (!auth()->user()->hasPermissionTo('view_any_permission')) {
abort(403);
}
Option B (Laravel Policy):
Gate::authorize('viewAny', Permission::class);
// Policy just wraps: return $user->hasPermissionTo('view_any_permission');
I've seen both approaches but get mixed advice:
-
Spatie docs seem to favor direct checks - Permission/Role models are "internal admin tools"
-
Laravel docs push policies - Consistent authorization pattern across app
-
My current setup: Already created PermissionPolicy ✅ registered ✅ working
Questions:
-
Is PermissionPolicy truly "over-engineering" for admin screens?
-
When Spatie already integrates with Gates ($user->can()), what's the value of wrapping it in a policy?
-
Community standard: Direct Spatie checks vs Policies for Permission/Role management?
Context:
- Laravel 12, Spatie v6
- Using policies successfully for business models (PostPolicy, UserPolicy, TicketPolicy)
- Permissions follow snake_case convention (view_any_permission)
Current working code:
Gate::authorize('viewAny', Permission::class);
// Policy
public function viewAny(User $user): bool
{
return $user->hasPermissionTo('view_any_permission');
}
Should I keep the policy pattern for consistency, or switch Permission/Role controllers to direct Spatie checks for simplicity?
I think about it this way. If you just want to check ABILITY then use a Gate. ie, can this user edit Users, yes or no? Use policies if you need control at the model level, ie can this user edit Users from team X. Your policy can consume permissions directly or via gates.
Gate = general ability.
Policy = ability to do something with specific thing.
Please or to participate in this conversation.