- Laravel 11.20+
- PHP 8.2+
- Spatie/laravel-permission 6.9+
- Filament 3.2.98+
To be able to use this package, you need to have spatie/laravel-permission v6.9+ installed. Then follow the installation guide of spatie/laravel-permission.
This has used a wildcard permission based.
So you must to set this on your config/permission.php
file, else it will throw an exception Please enable wildcard permission in your config/permission.php
.
// config/permission.php
'enable_wildcard_permission' => true,
You can install the package via composer:
composer require lloricode/filament-spatie-laravel-permission-plugin
You can publish the config file with:
php artisan vendor:publish --tag="filament-permission-config"
This is the contents of the published config file:
use Lloricode\FilamentSpatieLaravelPermissionPlugin\FilamentPermissionPlugin;
->plugins([
FilamentPermissionPlugin::make(),
])
// ...
use Lloricode\FilamentSpatieLaravelPermissionPlugin\Concern\PermissionUser;
use Lloricode\FilamentSpatieLaravelPermissionPlugin\Contracts\HasPermissionUser;
class Admin extends Authenticatable implements HasPermissionUser // ...
{
use PermissionUser;
// ...
// ...
use Lloricode\FilamentSpatieLaravelPermissionPlugin\Concern\PermissionPages;
use Lloricode\FilamentSpatieLaravelPermissionPlugin\Contracts\HasPermissionPages;
class MyPage extends Page implements HasPermissionPages
{
use PermissionPages;
// ...
// ...
use Lloricode\FilamentSpatieLaravelPermissionPlugin\Concern\PermissionWidgets;
use Lloricode\FilamentSpatieLaravelPermissionPlugin\Contracts\HasPermissionWidgets;
class MyWidget extends ChartWidget implements HasPermissionWidgets
{
use PermissionWidgets;
// ...
Finally, run this command to generate the permission.
php artisan permission:sync
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.