shanerbaner82 / panel-roles
Filament Panel Roles is an intuitive way to ensure all users of a specified panel within Filament v3 is assigned a role during registration and has a specified role using Laravel Middleware.
Installs: 3 118
Dependents: 0
Suggesters: 0
Security: 0
Stars: 13
Watchers: 1
Forks: 4
Open Issues: 3
Requires
- filament/support: ^3.0
README
Filament Panel Roles
Filament Panel Roles is an intuitive way to ensure all users of a specified panel within Filament v3 is assigned a role during registration and has a specified role using Laravel Middleware.
Installation
composer require shanerbaner82/panel-roles
Setup
Filament Panel Roles requires you to install Spatie's Laravel Permissions package. the minimum setup required is to:
- Install Spatie's package
- Add the RoleMiddleware to your
app/Http/Kernel.php
Usage
Inside any of your Filament panels add the Panel Roles plugin and specify the role users will be assigned and must have in order to login.
use Shanerbaner82\PanelRoles\PanelRoles; class AdminPanelProvider extends PanelProvider { public function panel(Panel $panel): Panel { return $panel ... ->plugin(PanelRoles::make() ->roleToAssign('developer') ->restrictedRoles(['admin', 'developer']), ) } }
Technically you do not need to chain the registration()
function on your panel, but if you do when a user registers they will be assigned the provided role.
Bonus
Watch LaravelOnline on YouTube to see how this plugin was created and to learn more about Laravel and Filament!