Roles with Spatie Permission Package

Filament 4
Also available in Filament 3 version

Shows how to use spatie/laravel-permission in Filament with auto-role assignment on registration and Policy-based resource authorization.

92J0K263t20Mz2ULmA84ok7Kwzq5JN-metaZmlsYW1lbnQtZXhhbXBsZXMtcm9sZXMtYW5kLXBlcm1pc3Npb25zLnBuZw==-

Get the Source Code:

How it works

The registration form is enabled in AdminPanelProvider.

app/Providers/Filament/AdminPanelProvider.php:

class AdminPanelProvider extends PanelProvider
{
public function panel(Panel $panel): Panel
{
return $panel
->default()
->id('admin')
->path('admin')
->login()
->registration() // here we enable registration feature
// ...
}
}

The spatie/laravel-permission package is used for the roles and permissions. Two roles are seeded: admin and user.

When a new user registers to the application, the user role is assigned using the closure Eloquent event created.

The FULL tutorial is available after the purchase: in the Readme file of the official repository you would get invited to.
Get the Source Code: All 152 Premium Examples for $99