afea / filament-users
User management module for the Afea Filament CMS package ecosystem: user listing/editing, role management and permission assignment backed by spatie/laravel-permission.
Requires
- php: ^8.4
- afea/filament-cms-core: @dev
- filament/filament: ^4.0
- illuminate/contracts: ^12.0
- illuminate/database: ^12.0
- illuminate/support: ^12.0
- laravel/prompts: ^0.3
- spatie/laravel-permission: ^6.0
Requires (Dev)
- laravel/pint: ^1.0
- orchestra/testbench: ^10.0
- pestphp/pest: ^4.0
- pestphp/pest-plugin-laravel: ^4.0
Suggests
- bezhansalleh/filament-shield: Auto-generates policy classes and per-resource permissions; when present, `afea:install:users` runs `shield:install` + `shield:generate --all` for you.
README
User management module for the Afea Filament CMS package ecosystem.
Ships:
UserResource— list/create/edit users with role attachmentRoleResource— list/create/edit roles with permission assignment (checkbox list)SuperAdminRoleSeeder— idempotent seed for thesuper_adminroleUsersPlugin+afea:install:usersinstaller
Wraps spatie/laravel-permission which is already required by afea/filament-cms-core — this package just adds the Filament admin UI and lifecycle commands.
Installation
composer require afea/filament-users php artisan afea:install:users
Then add the HasRoles trait to your App\Models\User:
use Illuminate\Foundation\Auth\User as Authenticatable; use Spatie\Permission\Traits\HasRoles; class User extends Authenticatable { use HasRoles; // ... }
Register in AdminPanelProvider:
->plugin(\Afea\Cms\Users\Filament\UsersPlugin::make())
Grant yourself the super-admin role:
php artisan tinker >>> App\Models\User::first()->assignRole('super_admin')
Three common scenarios
1. Use a different User subclass
AFEA_USERS_USER_MODEL="App\\Models\\AdminUser"
Or set the full config key:
// config/afea-users.php 'models' => [ 'user' => \App\Models\AdminUser::class, ],
2. Seed domain-specific permissions
Create your own seeder alongside SuperAdminRoleSeeder:
namespace Database\Seeders; use Spatie\Permission\Models\Permission; class PermissionSeeder extends \Illuminate\Database\Seeder { public function run(): void { collect(['view_posts', 'create_posts', 'edit_posts', 'delete_posts']) ->each(fn ($name) => Permission::findOrCreate($name, 'web')); } }
Then call php artisan db:seed --class=Database\\Seeders\\PermissionSeeder.
3. Filament Shield — auto-generated policies
bezhansalleh/filament-shield is a first-class companion. Install it before running our installer and we auto-run shield:install + shield:generate --all for you:
composer require bezhansalleh/filament-shield php artisan afea:install:users --force
The installer detects Shield via the shield:install Artisan command, asks for confirmation, and passes the configured panel id (default admin, change with --panel-id=cms). The super_admin role we seed matches Shield's convention, so existing accounts keep working.
If you install Shield after running our installer, just run Shield's commands manually:
php artisan shield:install admin php artisan shield:generate --all --panel=admin
Skip Shield with --skip-shield even when it is installed (useful for CI).