Filament Hexa is an easy-to-use role and permission management plugin for Filament. Now in version 3, it supports Filament 4, multi-panel setups, is easier to use, and customizable.
This version doesn’t bring major changes yet—it mainly focuses on supporting Filament v4 and includes minor bug fixes. We intentionally bumped the version to help identify version alignment between Hexa and Filament. In the future, if Filament increases its major version, Hexa will likely follow with a major version increase as well.
| Hexa | Filament | Documentation |
|---|---|---|
| V1 | v3 | Read Documentation |
| V2 | v3 | Read Documentation |
| V3 | v4 | Read Documentation |
- 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
Install the package:
composer require hexters/hexaThen run the migration for the roles table:
php artisan migrateAfter 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 your User model:
use Hexters\Hexa\HexaRolePermission;
class User extends Authenticatable
{
use HasFactory, Notifiable;
use HexaRolePermission; // Add this trait
}To assign a role to a user, add a select input in your UserForm class:
use Filament\Forms\Components\Select;
. . . .
Select::make('roles')
->label(__('Role Name'))
->relationship('roles', 'name')
->placeholder(__('Superuser')),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 the guards in config/auth.php.
Permissions can be defined in Pages, Resources, Widgets, and Clusters. Example:
use Hexters\Hexa\HasHexaRole;
. . .
use HasHexaRole;
public function defineGates(): array
{
return [
'user.index' => __('Allows viewing the user list'),
'user.create' => __('Allows creating a new user'),
'user.update' => __('Allows updating a user'),
'user.delete' => __('Allows deleting a user'),
];
}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');
}To check access outside of an authenticated context (e.g., in queues or commands):
return hexa()->user(User::first())->can('user.index');Filament supports visible on components like Action, Column, Input, etc.:
Actions\CreateAction::make('create')
->visible(fn() => hexa()->can(['user.index', 'user.create']));You can also use Laravel's native authorization:
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');
use Hexters\Hexa\HasHexaRole;
. . .
use HasHexaRole;
public function roleName()
{
return __('User Account');
}
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'),
];
}Menu order follows the navigation order. If you want to distinguish it:
public $hexaSort = 4;You can define additional gates using GateItem:
Hexa::make()
->gateItems([
GateItem::make(__('Horizon'))
->description(__('Allows user to manage the horizon page'))
->gateItems([
'horizon.page' => __('Horizon Page')
])
->gateItemDescriptions([
'other.index' => __('Allow user to access horizon page')
]),
]);To customize the menu:
use Filament\Support\Icons\Heroicon;
. . .
Hexa::make()
->shouldRegisterNavigation(true)
->navigationName(__('Role & Access'))
->navigationGroup('Settings')
->navigationIcon(Heroicon::OutlinedLockOpen)
->gateItems([...]);Filament Hexa supports multi-tenancy. The HexaRole model includes a team_id field and a team relationship. You can integrate it with Filament’s multi-tenancy system.
To override the role model (e.g., to customize tenant relationships), publish the config:
php artisan vendor:publish --provider="Hexters\Hexa\HexaServiceProvider"hexa()->setOption('key-option', 'value-option');
hexa()->getOption('key-option', 'default');
hexa()->dateOption('key-option');
hexa()->getOptionKeys();| 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 |
Filament Hexa requires a valid license to operate.
You can purchase and activate your license directly through the link below:
🔗 https://buymeacoffee.com/hexters/e/476730
All purchases and support are greatly appreciated and contribute to the ongoing development of Filament Hexa ❤️
Please report any issues via GitHub: Filament Hexa Issue Tracker
Thank you for using Filament Hexa. We hope this helps speed up your development process.
Happy Coding! 🧑💻
