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.
23,432 16
Install
composer require shanerbaner82/panel-roles
Latest Version:v0.0.3
License:MIT
Last Updated:Oct 10, 2023
Links: GitHub  ·  Packagist
Maintainer: shanerbaner82

Filament Panel Roles

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:

  1. Install Spatie's package
  2. Add the RoleMiddleware to yourapp/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!

Related Packages

doctrine/dbal

Powerful PHP database abstraction layer (DBAL) with many features for database s...

631,580,251 9,707
laravel/framework

The Laravel Framework.

580,311,802 34,925
laravel/tinker

Powerful REPL for the Laravel framework.

489,754,436 7,444
laravel/serializable-closure

Laravel Serializable Closure provides an easy and secure way to serialize closur...

404,034,618 608
nunomaduro/collision

Cli error handling for console/command-line PHP applications.

384,821,166 4,658