What problem does it solve?
This Skill helps Laravel applications implement robust access control and multilingual models using Spatie's permissions package and Translatable models, reducing boilerplate and errors.
Core Features & Use Cases
- RBAC with roles and permissions: Define and enforce role-based access across controllers, routes, and policies.
- Translatable models: Build models whose attributes are stored in multiple locales with automatic fallback support.
- Authorization policies & middleware: Centralize permission checks in policies and protect resources via middleware.
Use Case: A multilingual CMS where editors manage content in several locales while admins control access to admin sections via roles and permissions.
Quick Start
Install the required packages with Composer: composer require spatie/laravel-permission spatie/laravel-translatable. Run migrations: php artisan migrate. Seed initial roles and permissions and attach them to models. Protect routes with middleware 'permission:*' and implement policies to enforce access.