webrek/laravel-mongo-permission-filament
Filament admin panel integration for MongoDB-backed roles and permissions in Laravel. Manage, assign, and audit access control through native Filament resources, making permission management simpler for Mongo-powered applications.
mongodb connection in config/database.php before touching the package. This stack stores roles/permissions in MongoDB, not SQL.composer require <package> webrek/laravel-mongo-permission:^1.5. The ^1.5 constraint matters — it contains the legacy flat-data fix and cache invalidation improvements this release depends on.php artisan vendor:publish) and review the guard/model settings. There are no SQL migrations to run; MongoDB collections are created on first write.webrek/laravel-mongo-permission (e.g. HasRoles) to your authenticatable model, typically App\Models\User. Confirm the model extends the MongoDB Eloquent base model expected by webrek.->plugins([...]) in AdminPanelProvider. This registers the Role and Permission resources bound to the Mongo models.$user->assignRole('admin')) and verify with $user->can('...').firstOrCreate(['name' => 'posts.publish', 'guard_name' => 'web']), then sync them to roles.$user->can(...), @can, policies). Avoid querying the Mongo role collections directly in controllers.canViewAny/canCreate etc. call $user->can(...). This keeps panel access aligned with the same permission data edited in the UI.guard_name explicitly everywhere — in seeders, in resource forms, and on the User model’s guard. Filament panel guards must match the permission backend’s guard.RefreshDatabase (which is SQL-oriented).^1.5 backend adds cache invalidation, but explicitly forgetting cached permissions after programmatic bulk changes is still a safe pattern.composer why-not before upgrading an existing project.^1.5 backend includes a legacy flat-data fix. If you are migrating from an older Mongo permission schema, test role/permission reads carefully and inspect documents for old shapes before relying on the UI.can() returns false” is a guard mismatch between the role/permission documents, the User model, and the Filament panel. Keep guard_name consistent.RefreshDatabase: Use MongoDB-specific cleanup in tests. The package’s new test suite is a good reference for asserting resource/model binding without assuming SQL migrations.How can I help you explore Laravel packages today?