lloricode / filament-spatie-laravel-permission-plugin
This is my package filament-spatie-laravel-permission-plugin
Fund package maintenance!
lloricode
Installs: 1 275
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Requires
- php: ^8.2
- filament/filament: ^3.2.98
- illuminate/contracts: ^11.20
- spatie/laravel-package-tools: ^1.16.4
- spatie/laravel-permission: ^6.9
Requires (Dev)
- larastan/larastan: ^2.9.8
- laravel/pint: ^1.17.2
- nunomaduro/collision: ^8.4
- orchestra/testbench: ^9.2
- pestphp/pest: ^3.2.5
- pestphp/pest-plugin-arch: ^3.0
- pestphp/pest-plugin-laravel: ^3.0
- pestphp/pest-plugin-livewire: ^3.0
- phpstan/extension-installer: ^1.4.1
- phpstan/phpstan-deprecation-rules: ^1.2
- phpstan/phpstan-phpunit: ^1.4
- spatie/laravel-ray: ^1.37.1
- ticketswap/phpstan-error-formatter: ^1.1
README
Requirements
- Laravel 11.20+
- PHP 8.2+
- Spatie/laravel-permission 6.9+
- Filament 3.2.98+
Pre-requisite
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,
Installation
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:
Usage
use Lloricode\FilamentSpatieLaravelPermissionPlugin\FilamentPermissionPlugin; ->plugins([ FilamentPermissionPlugin::make(), ])
Setting up user model
// ... use Lloricode\FilamentSpatieLaravelPermissionPlugin\Concern\PermissionUser; use Lloricode\FilamentSpatieLaravelPermissionPlugin\Contracts\HasPermissionUser; class Admin extends Authenticatable implements HasPermissionUser // ... { use PermissionUser; // ...
Setting up Filament pages
// ... use Lloricode\FilamentSpatieLaravelPermissionPlugin\Concern\PermissionPages; use Lloricode\FilamentSpatieLaravelPermissionPlugin\Contracts\HasPermissionPages; class MyPage extends Page implements HasPermissionPages { use PermissionPages; // ...
Setting up Filament widgets
// ... 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
Testing
composer test
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.