Filament Role & Permission Effortless

Last update 08/09/25 07:59 UTC Private

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 -g 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

Hexa v3 & Filament v4

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.

Banner

Versions

Hexa Filament Documentation
V1 v3 Read Documentation
V2 v3 Read Documentation
V3 v4 Read Documentation

Index

Installation

Install the package:

composer require hexters/hexa

Then run the migration for the roles table:

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 your 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 UserForm class:

use Filament\Forms\Components\Select;

. . . .

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 the guards in config/auth.php.

Defining Permissions

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'),
    ];
}

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

To check access outside of an authenticated context (e.g., in queues or commands):

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

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');

Additional Methods (optional)

Adding Descriptions to Roles and Gates

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'),
    ];
}

Setting Role Display Order

Menu order follows the navigation order. If you want to distinguish it:

public $hexaSort = 4;

Custom Access

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([...]);

Multi Tenancy

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.

Vendor Publish

To override the role model (e.g., to customize 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

Filament Hexa requires a valid license. Support the developer and purchase a license here: 👉 https://ppmarket.org/browse/hexters-hexa

Bug Reports or Issues

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! 🧑‍💻

Release Versions

  • 3.0.2 09/08/2025
  • 3.0.1 08/22/2025
  • 3.0.0 08/14/2025
  • 2.0.3 08/08/2025
  • 2.0.2 08/07/2025
  • 2.0.1 07/07/2025
  • 2.0.0 06/24/2025
  • 1.3.7 11/06/2024
  • 1.3.3 08/13/2024
  • 1.3.2 07/06/2024
  • 1.3.1 07/06/2024
  • 1.2.2 07/01/2024
  • 1.2.1 06/25/2024
  • 1.2.0 06/24/2024
  • 1.1.3 06/24/2024
  • 1.1.2 06/24/2024
  • 1.1.1 06/24/2024
  • 1.1.0 06/23/2024
  • 1.0.2 06/22/2024
  • 1.0.0 06/22/2024

0

base on 0 ratings

0%
0%
0%
0%
0%
Purchase

4

Download

172