From 13c8b45f8727c1b2cb71555904adba062762e496 Mon Sep 17 00:00:00 2001 From: Bezhan Salleh Date: Sat, 23 Sep 2023 18:31:57 +0430 Subject: [PATCH] panel user doc added --- README.md | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 3cf709c..914f21b 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ filament-shield-art -

+

FILAMENT 8.x @@ -81,6 +81,24 @@ Follow the prompts and enjoy! ## Filament Panels If you want to enable `Shield` for more than one panel then you need to register the plugin for each panel as mentioned above. +### Panel Access +Shield comes with the `HasPanelShield` trait which provides an easy way to integrate Shield's conventions with the Filament's panel access system. + +The `HasPanelShield` trait provides an implementation for the `canAccessPanel` method, determining access based on whether the user possesses the `super_admin` role or the `panel_user` role. It also assigns the `panel_user` role to the user upon creation and removes it upon deletion. Ofcourse the role names can be changed from the plugin's configuration file. + +```php +use BezhanSalleh\FilamentShield\Traits\HasPanelShield; +use Filament\Models\Contracts\FilamentUser; +use Illuminate\Foundation\Auth\User as Authenticatable; +use Spatie\Permission\Traits\HasRoles; + +class User extends Authenticatable implements FilamentUser +{ + use HasRoles; + use HasPanelShield; + // ... +} +``` #### Resources Generally there are two scenarios that shield handles permissions for your `Filament` resources.