One Plugin to rule them all, One Plugin to find them, One Plugin to bring them all, and in the light bind them, In the Land of Filament where building them is really fun!
- Install the package via composer:
composer require bezhansalleh/filament-shield
- Publish the config file with:
php artisan vendor:publish --tag="filament-shield-config"
- Configure
super_admin
role and change therole_name
to something of your choosing. It is recommend to leave it enable this way everypermission
generated will be automatically assigned to this role. then you would only need to assign this role to your super adminuser
.
'super_admin' => [
'enabled' => true,
'role_name' => 'super_admin',
],
- Now run the following command to setup everything:
php artisan shield:install
Follow the prompts and enjoy!
- For existing apps run the following command to setup everything:
php artisan shield:install --fresh
Beaware, that even though there are checks in place but if confirmed; existing policies might get overwritten.
To ensure RoleResource
access via RolePolicy
you would need to add the following to your AuthServiceProvider
:
//AuthServiceProvider.php
...
protected $policies = [
'Spatie\Permission\Models\Role' => 'App\Policies\RolePolicy',
];
...
Optionally, you can publish the translations using
php artisan vendor:publish --tag="filament-shield-translations"
shield:create # Create Permissions and/or Policy for the given Filament Resource Model
shield:generate # (Re)Discovers Filament resources and (re)generates Permissions and Policies.
shield:install # One Command to Rule them All 🔥
shield:publish # Publish filament shield's Resource.
- Imporve documentation 📝
- A command to reverse everything 🤯
- handle
except
oronly
options for Permission and Policy generation 👀 - improve automation or add new features... ⏭
composer test
Please see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
Please review our security policy on how to report security vulnerabilities.
The MIT License (MIT). Please see License File for more information.