aluisio-pires / permissions
Permission handling for Laravel 8.0 and up
v0.1.19
2025-03-03 12:12 UTC
Requires
- php: ^8.0
- illuminate/auth: ^8.12|^9.0|^10.0|^11.0|^12.0
- illuminate/container: ^8.12|^9.0|^10.0|^11.0|^12.0
- illuminate/contracts: ^8.12|^9.0|^10.0|^11.0|^12.0
- illuminate/database: ^8.12|^9.0|^10.0|^11.0|^12.0
- spatie/laravel-permission: ^6.15
Requires (Dev)
- laravel/passport: ^11.0|^12.0
- laravel/pint: ^1.21
- orchestra/testbench: ^6.23|^7.0|^8.0|^9.0|^10.0
- phpunit/phpunit: ^9.4|^10.1|^11.5
README
Requirements:
Features:
- Access control list (ACL) tool / menu
- Roles and Permissions Filament pages
Installation
-
Make sure you have your Laravel Filament installed:
-
Add the package with composer:
composer require pdmfc/filament-permission
Configuration
- Create Files
php artisan filament-permission:create-files
- Run migrations
php artisan migrate
- Now you can add the
hasRoles
trait to yourUser
model to enable the authorization
...
class User extends Authenticatable
{
/** @use HasFactory<\Database\Factories\UserFactory> */
use HasFactory, HasRoles, Notifiable;
...
- If your
User
model has theSoftDeletes
trait, you can remove the commented code fromUsersRelationManager
class to enable the trashed filter.
...
->filters([
Tables\Filters\TrashedFilter::make(),
])
Usage
Add the admin
role to your user and access your filament admin panel to see the new Administration
navigation group.
Example:
User::factory()->create([ 'name' => 'Test User', 'email' => 'test@example.com', ])->assignRole('admin');
More information
It's recommended to read the Spatie/Laravel-Permission documentation at: https://spatie.be/docs/laravel-permission/v6/introduction