laravel-permission-development

Implement roles, permissions, middleware, and Blade directives with Spatie Laravel Permission.

Updated Sep 19, 2026
One-click install
npx skills add https://github.com/idehen-divine/lumished --skill laravel-permission-development-idehen-divine
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: laravel-permission-development
Source: https://github.com/idehen-divine/lumished/tree/main/.agents/skills/laravel-permission-development
Command: npx skills add https://github.com/idehen-divine/lumished --skill laravel-permission-development-idehen-divine

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires spatie/laravel-permission.

What problem does it solve? Managing authorization in Laravel applications requires correctly wiring roles, permissions, middleware, policies, and Blade directives, and mistakes lead to broken access control or stale permission caches. ## Core Features & Use Cases - Role and Permission Management: Create, assign, sync, and revoke roles and permissions using Spatie models, traits, and enums. - Access Enforcement: Apply role and permission middleware to routes, check authorization with $user->can(), and render conditional UI with Blade directives. - Advanced Patterns: Configure Super Admin via Gate::before, write permission-based policies, seed roles idempotently, and enable teams for multi-tenancy. - Use Case: When building an admin panel, use this Skill to define a 'writer' role with 'edit articles' permission, protect routes with middleware, and hide edit buttons in Blade for unauthorized users. ## Quick Start Ask the AI to set up Spatie Laravel Permission with roles, permissions, middleware, and a seeder for your Laravel application.

Frequently Asked Questions about laravel-permission-development

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I set up roles and permissions in Laravel?▼

Install spatie/laravel-permission, add the HasRoles trait to your User model, then create roles and permissions with Role::create() and Permission::create(). Assign roles to users with assignRole() and grant permissions to roles with givePermissionTo().

How to protect Laravel routes with role or permission middleware?▼

Register the role, permission, and role_or_permission middleware aliases in bootstrap/app.php, then apply them to routes like middleware(['permission:edit articles']). Use a pipe character for OR logic, such as role:manager|writer.

Should I check permissions or roles in Laravel authorization?▼

Check permissions, not roles, using $user->can('permission-name') for all authorization logic. Roles should group permissions, and permission checks support Super Admin overrides via Gate::before, while direct role checks bypass the Gate.

How do I create a Super Admin with spatie/laravel-permission?▼

Add a Gate::before callback in AppServiceProvider::boot() that returns true when the user has the Super Admin role. It must return null for other users so normal permission checks still run.

Why are my seeded permissions not working in Laravel?▼

The package caches permissions, so stale cache causes seeded changes to be ignored. Call forgetCachedPermissions() on the PermissionRegistrar before seeding and after any direct database inserts like Permission::insert().

Does spatie/laravel-permission support multi-tenant teams?▼

Yes, enable the teams option in config/permission.php before running migrations, then set the active team with setPermissionsTeamId() in middleware. When switching teams, unset the cached roles and permissions relations on the user.