tiagolemosneitzke / filamentacl
A flexible and lightweight Access Control List (ACL) plugin for managing user permissions and roles in Laravel applications
Fund package maintenance!
filament-acl
Requires
- php: ^8.2
- spatie/laravel-package-tools: ^1.15.0
- spatie/laravel-permission: ^6.9
Requires (Dev)
- laravel/pint: ^1.0
- nunomaduro/collision: ^7.9
- nunomaduro/larastan: ^2.0.1
- orchestra/testbench: ^8.0
- pestphp/pest: ^2.36
- pestphp/pest-plugin-arch: ^2.0
- pestphp/pest-plugin-laravel: ^2.0
- phpstan/extension-installer: ^1.1
- phpstan/phpstan-deprecation-rules: ^1.0
- phpstan/phpstan-phpunit: ^1.0
This package is auto-updated.
Last update: 2025-05-12 06:42:53 UTC
README
A flexible and lightweight Access Control List (ACL) plugin for managing user permissions and roles in Laravel applications using Filament.
Attention
This package doesn't work with Tenancy.
You can install the package via composer:
composer require tiagolemosneitzke/filamentacl -W
This will install the Filament ACL package along with its dependencies, including spatie/laravel-permission
.
After the installation, publish the migration and configuration files:
php artisan vendor:publish --provider="Spatie\Permission\PermissionServiceProvider"
Run the migrations to create the necessary tables:
php artisan migrate
Add the HasRoles
trait to your User model:
use Spatie\Permission\Traits\HasRoles; class User extends Authenticatable { use HasRoles; }
Register the plugin in your Panel provider:
use TiagoLemosNeitzke\FilamentAcl\FilamentAclPlugin; public function panel(Panel $panel): Panel { return $panel ->plugins([ FilamentAclPlugin::make() ]); }
You can then install the Filament ACL package with the following command:
php artisan filament-acl:install
This will publish the config file.
Alternatively, you can publish only the config file with:
php artisan vendor:publish --tag="filament-acl-config"
This is the contents of the published config file:
return [ 'permission' => [ 'prefixes' => [ 'view', 'view_any', 'create', 'update', 'restore', 'delete', 'force_delete' ] ], 'roles_prefixes' => [ 'admin', ] ];
Also, you can publish manually all the files with:
php artisan vendor:publish --provider="TiagoLemosNeitzke\FilamentAcl\FilamentAclServiceProvider"
Or you can publish the necessary files one by one
php artisan vendor:publish --tag=filament-acl-config php artisan vendor:publish --tag=filament-acl-stubs
You don't need to publish all the files for the package work, but you need to publish the settings file and configuring correctly the Laravel Permissions Package.
In your UserResource
file, you should add the below code to edit and view the permission of the user:
use TiagoLemosNeitzke\FilamentAcl\Models\Role; public static function form(Form $form): Form { return $form ->schema([ Forms\Components\Select::make('roles') ->label('Role') ->relationship('roles', 'name') ->options(Role::all()->pluck('name', 'id')) ->multiple() ->preload() ->searchable(), ]); } public static function table(Table $table): Table { return $table ->columns([ Tables\Columns\TextColumn::make('roles.name') ->label('Is Admin?') ->badge(), ]); }
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.