Filament Role & Permission Effortless
Filament Hexa is a effortless role and permission management plugin for Filament
Installing Via Composer
Following CLI command to add the Composer repository to your composer.json
file.
composer config repositories.filamenthexa.ppmarket.org \
'{"type": "composer", "url": "https://filamenthexa.ppmarket.org"}' \
--file composer.json
To avoid manually typing these credentials, you may create a Composer auth.json file while using your license key in place of your password:
composer config http-basic.filamenthexa.ppmarket.org [email protected] your-license-key
After your composer.json
file has been updated, run the command below to start install this
package:
composer require hexters/hexa
Filament Hexa
Filament Hexa is an easy-to-use role and permission management plugin for Filament. Now in version 2, it supports multi-panel setups, is easier to use, and customizable.
Index
- Installation
- Adding Role Select
- Multi Panel
- Defining Permissions
- Granting Access
- Additional Methods (optional)
- Custom Access
- Multi Tenancy
- Vendor Publish
- Meta Options
- Traits Class
- License
- Bug Reports or Issues
Installation
To install Filament Hexa, add the package repository to your composer.json
file and run:
composer config repositories.filament-hexa.hexters.com \
'{"type": "composer", "url": "https://filament-hexa.hexters.com"}' \
--file composer.json
Then install the package:
composer require hexters/hexa
When prompted, enter your license credentials:
Authentication required (filament-hexa.hexters.com):
Username: 872620646
Password: cf3c8208-7537-451f-9aad-f93771c6b2f6
Info: Hi Asep, thank you for using Filament Hexa.
./composer.json has been updated
Running composer update hexters/hexa
- Installing hexters/hexa (2.0.0): Extracting archive
Generating optimized autoload files
Then run the migration for roles:
php artisan migrate
After installation, register the plugin in your panel:
use Filament\Panel;
use Hexters\Hexa\Hexa;
public function panel(Panel $panel): Panel
{
return $panel
->plugins([
Hexa::make(),
]);
}
Then register the access trait in the User
model:
use Hexters\Hexa\HexaRolePermission;
class User extends Authenticatable
{
use HasFactory, Notifiable;
use HexaRolePermission; // Add this trait
}
Adding Role Select
To assign a role to a user, add a select input in your UserResource
form:
Forms\Components\Select::make('roles')
->label(__('Role Name'))
->relationship('roles', 'name')
->placeholder(__('Superuser')),
Multi Panel
Filament Hexa supports multiple panels as long as each panel uses a different Auth Guard
. The default guard is web
.
public function panel(Panel $panel): Panel
{
return $panel
->authGuard('reseller');
}
public function panel(Panel $panel): Panel
{
return $panel
->authGuard('customer');
}
Configure guards in config/auth.php
.
Defining Permissions
Permissions can be declared in Pages, Resources, Widgets, and Clusters. Example:
public function defineGates(): array
{
return [
'user.index' => __('Allows to view list of users'),
'user.create' => __('Allows to create new user'),
'user.update' => __('Allows to update user'),
'user.delete' => __('Allows to delete user'),
];
}
Granting Access
If a user has no assigned role, they are treated as a Superuser
, meaning they can access all defined permissions.
public static function canAccess(): bool
{
return hexa()->can('user.index');
}
Check for User
When checking access outside an authenticated context (e.g., in queues or commands), use:
return hexa()->user(User::first())->can('user.index');
Visible Access
Filament supports visible
on components like Action
, Column
, Input
, etc.:
Actions\CreateAction::make('create')
->visible(fn() => hexa()->can(['user.index', 'user.create']));
Laravel Access
Laravel's native authorization features:
Auth::user()->can('user.create');
Gate::allows('user.create');
// Only works in authenticated context (e.g., requests)
Gate::forUser(User::first())->allows('user.create');
@can('user.create')
...
@endcan
✅ For non-authenticated contexts:
hexa()->user(User::first())->can('user.create');
Additional Methods (optional)
Adding Descriptions to Roles and Gates
public function roleDescription(): ?string
{
return __('Controls access to create, read, update, delete, and more.');
}
public function defineGateDescriptions(): array
{
return [
'user.index' => __('Admins can access the User page'),
'user.create' => __('Admins can create new Users'),
];
}
Setting Role Display Order
public $hexaSort = 4;
Custom Access
You can define additional gates using GateItem
:
Hexa::make()
->gateItems([
GateItem::make(__('Horizon'))
->description(__('Allows user to manage horizon page'))
->gateItems([
'horizon.page' => __('Horizon Page')
])
->gateItemDescriptions([
'other.index' => __('Allow user to access horizon page')
]),
]);
To customize the menu:
Hexa::make()
->shouldRegisterNavigation(true)
->navigationName(__('Role & Access'))
->navigationGroup('Settings')
->navigationIcon('heroicon-o-lock-open')
->gateItems([...]);
Multi Tenancy
Filament Hexa supports multi-tenancy. The HexaRole
model includes a team_id
field and team
relationship. You can integrate it with Filament's multi-tenancy setup.
Vendor Publish
To override the role model (e.g., for customizing tenant relationships), publish the config:
php artisan vendor:publish --provider="Hexters\Hexa\HexaServiceProvider"
Meta Options
hexa()->setOption('key-option', 'value-option');
hexa()->getOption('key-option', 'default');
hexa()->dateOption('key-option');
hexa()->getOptionKeys();
Traits Class
Name | Description |
---|---|
HexaRolePermission |
Used on the Authenticatable model |
HasHexaRole |
Used on Resources, Pages, Widgets, Clusters |
UuidGenerator |
Used on models with a uuid field |
UlidGenerator |
Used on models with a ulid field |
License
This plugin is not open-source. A valid license is required. You can purchase a license via Filament Hexa License or contact the developer directly.
Bug Reports or Issues
Please report issues via GitHub: Filament Hexa Issue Tracker
Thank you for using Filament Hexa. We hope it helps accelerate your development process.
Happy Coding! 🧑💻
Keywords
Hexa plugin
role and permission Filament
role management Filament
access permissions Filament
Hexa Filament
Hexa plugin
hexters ladmin
Hexa installation
Filament integration
Filament permission setup
Filament access control
role management PHP
Filament panel
Filament resource access
Filament widget permissions
0
base on 0 ratings