### Install Package via Composer Source: https://github.com/jhonoryza/filament-simple-role-permission/blob/main/README.md Installs the filament-simple-role-permission package as a development dependency using Composer. ```bash composer require --dev jhonoryza/filament-simple-role-permission ``` -------------------------------- ### Run Database Migrations Source: https://github.com/jhonoryza/filament-simple-role-permission/blob/main/README.md Applies the database migrations generated by the package to set up the necessary tables for roles and permissions. ```bash php artisan migrate ``` -------------------------------- ### Seed Default Roles and Permissions Source: https://github.com/jhonoryza/filament-simple-role-permission/blob/main/README.md Executes artisan commands to seed the database with default roles, permissions, and a super-admin user, populating the system with initial data. ```bash php artisan db:seed --class=PermissionSeeder php artisan db:seed --class=RoleSeeder php artisan db:seed --class=UserSeeder ``` -------------------------------- ### Publish Package Scaffolding Source: https://github.com/jhonoryza/filament-simple-role-permission/blob/main/README.md Runs the artisan command to publish the package's scaffolding files, including migrations and seeders. ```bash php artisan filament-simple-role-permission:install ``` -------------------------------- ### Generate Policy Files Source: https://github.com/jhonoryza/filament-simple-role-permission/blob/main/README.md Generates policy files in the app\Policies directory based on the predefined permissions defined in the Permission model. This helps in authorization. ```bash php artisan policy:generate ``` -------------------------------- ### Publish Policy Stubs Source: https://github.com/jhonoryza/filament-simple-role-permission/blob/main/README.md Publishes the policy class templates, allowing developers to customize the structure and content of generated policy files. ```bash php artisan vendor:publish --tag="simple-role-permission-stubs" ``` -------------------------------- ### Configure Permission Model Source: https://github.com/jhonoryza/filament-simple-role-permission/blob/main/README.md Customizes predefined permissions and their mapping to authorization methods within the Permission model. This allows fine-grained control over what actions are permitted. ```php public static function getPredefined(): array { return [ 'users' => [ 'view-any', 'view', 'create', 'update', 'delete', 'bulk-delete', ], 'roles' => [ 'view-any', 'view', 'create', 'update', 'delete', 'bulk-delete', ], 'permissions' => [ 'view-any', 'view', 'create', 'update', 'delete', 'bulk-delete', ], ]; } public static function match($permission): string { return match ($permission) { 'view-any' => 'viewAnyPermission', 'view' => 'viewPermission', 'create' => 'createPermission', 'update' => 'updatePermission', 'delete' => 'deletePermission', 'bulk-delete' => 'bulkDeletePermission', default => '', }; } ``` -------------------------------- ### Configure User Model for Roles Source: https://github.com/jhonoryza/filament-simple-role-permission/blob/main/README.md Modifies the User model to include the HasRole trait and define predefined roles for the application. This is crucial for associating users with roles. ```php use App\Models\Concern\HasRole; class User extends Authenticatable { use HasRole; const SUPER = 'super-admin'; const ADMIN = 'admin'; public static function getPredefined(): array { return [ self::SUPER, self::ADMIN, ]; } protected $fillable = [ // ... etc 'role_id', ] } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.