Download the PHP package agroezinger/filament-shield-enhanced without Composer
On this page you can find all versions of the php package agroezinger/filament-shield-enhanced. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download agroezinger/filament-shield-enhanced
More information about agroezinger/filament-shield-enhanced
Files in agroezinger/filament-shield-enhanced
Package filament-shield-enhanced
Short Description Fine-grained page permissions & structured UI addon for bezhansalleh/filament-shield.
License MIT
Homepage https://github.com/agroezinger/filament-shield-enhanced
Informations about the package filament-shield-enhanced
Filament Shield Enhanced
[!WARNING] Testing Phase: Versions
0.0.*are currently in the testing phase. At present, there are no known bugs.
A standalone addon for bezhansalleh/filament-shield that adds fine-grained page and resource permissions and a structured Role Resource UI — without forking or replacing the original package.
Why this exists.
The features were proposed upstream in bezhanSalleh/filament-shield#698. The author has not had time to review the PR. This addon ships the same functionality as a composable layer on top of the official package.
Features
| Feature | Description |
|---|---|
| Multi-action page permissions | Declare several permissions per page via getShieldPagePermissions(). |
| Multi-action resource permissions | Declare custom permissions per resource via getShieldResourcePermissions() — beyond the standard CRUD policy methods. |
canShield('action') |
Fluent, type-safe permission check — instance method on Pages, static method on Resources. |
getShieldPermissions() |
Returns a pre-resolved action → bool map for injection into child Livewire components. |
HasInjectedShieldPermissions |
Trait for child Livewire components that receive the map from the parent page. |
EnhancedPagePermissionsForm |
Form builder helper for the published RoleResource — renders each enhanced page as a separate Section with individual checkboxes. |
EnhancedResourcePermissionsForm |
Form builder helper for the published RoleResource — renders each enhanced resource as a separate Section with individual checkboxes. |
| Three-part page key convention | {Prefix}{sep}{Action}{sep}{Subject} (e.g. Page:EditSettings:SettingsPage) — fully respects filament-shield's separator and case config. |
| Two-part resource key convention | {Action}{sep}{ModelBasename} (e.g. ViewContactInfo:Member) — matches Shield's own resource permission format, no extra prefix. |
| Zero conflict | Does not replace any original class. Falls back gracefully on entities that do not declare the method. |
Requirements
| Dependency | Version |
|---|---|
| PHP | ^8.2 |
| Laravel | ^11.0 | ^12.0 | ^13.0 |
| Filament | ^4.0 | ^5.0 |
| bezhansalleh/filament-shield | ^4.0 |
Installation
Publish the config (optional):
Usage — Pages
1 — Declare fine-grained permissions on a Page
Replace (or complement) the original HasPageShield with the enhanced version:
Then run the enhanced generator to create the permissions in the database:
Use
--panel=<id>to limit the scan to a single panel.
This will create three permissions for the page above:
2 — Check permissions in PHP (Pages)
3 — Inject permissions into child Livewire components
Parent page Blade:
Child Livewire component:
Usage — Resources
4 — Declare fine-grained permissions on a Resource
Add HasResourceShield to any Filament Resource and declare custom actions via getShieldResourcePermissions():
Then create the permissions in the database:
This will create (for the example above):
The key format (Action:ModelBasename) is identical to Shield's own resource permission format so everything looks consistent.
5 — Check resource permissions in PHP
canShield() is a static method on Resources (unlike Pages, where it is an instance method):
Super-admin bypass is applied automatically — identical behaviour to the page trait.
6 — Structured UI in the published RoleResource
After publishing the RoleResource with php artisan shield:publish --panel=<id> two files need small changes.
6a — RoleResource: add both enhanced tabs
Open the published RoleResource.php and override two methods:
Each Resource that declares getShieldResourcePermissions() appears in the "Resources (Fine-grained)" tab as its own Section with individual checkboxes.
Note: Shield's standard "Resources" tab only shows CRUD policy method permissions (
ViewAny,Create,Update, …). Custom resource actions do not appear there — no duplicate-filtering override is needed.
6b — EditRole: add the pre-fill trait
Open the published EditRole.php and add use HasEnhancedRoleForm. This pre-fills both page- and resource-permission checkboxes when the form opens.
The mutateFormDataBeforeSave() / afterSave() logic from Shield's own EditRole handles saving — no additional overrides needed.
Configuration
How it works internally
This addon does not override any class from filament-shield. Instead it uses the package's public extension point:
When a Page class exposes getShieldPagePermissions(), the addon intercepts the key builder and applies its three-part naming convention. All other entities (Resources, Widgets, regular Pages) are delegated back to the original builder unchanged.
Resource permissions use a two-part format matching Shield's own convention and are not created via shield:generate — only via shield:generate-enhanced-resources. This means the hook is not involved for Resources at all.
Upgrading from the fork
If you previously used the agroezinger/filament-shield fork (which is a modified copy of the original package):
-
Switch
composer.jsonback to the official package: - Replace
use BezhanSalleh\FilamentShield\Traits\HasPageShieldwith
use Agroezinger\FilamentShieldEnhanced\Traits\HasPageShieldin your pages. - Replace
use BezhanSalleh\FilamentShield\Traits\HasInjectedShieldPermissions(if used) with
use Agroezinger\FilamentShieldEnhanced\Traits\HasInjectedShieldPermissions. - Re-run
php artisan shield:generate --allso the new three-part keys are created.
Changelog
See CHANGELOG.md.
License
MIT — see LICENSE.md.
Credits
- Alexander Groezinger — addon author
- Bezhan Salleh — original filament-shield package
All versions of filament-shield-enhanced with dependencies
bezhansalleh/filament-shield Version 4.2.0
filament/filament Version ^4.0|^5.0
illuminate/contracts Version ^11.28|^12.0|^13.0
illuminate/support Version ^11.28|^12.0|^13.0
spatie/laravel-package-tools Version ^1.92