Package

Hexters Hexa Lite

Filament Hexa is a effortless role and permission management plugin for Filament

Package

hexters/hexa-lite

View on GitHub →

Filament Hexa Lite

Filament Hexa Lite is an effortless role & permission plugin for Filament, inspired by the concept of hexters/ladmin. This concept facilitates managing each role and permission inline with code and provides an easy-to-understand interface.

This plugin is intended only for Administrators, as it has a separate admin table from the user table provided by Laravel. Additionally, this plugin will replace the auth.php configuration file.

About Filament

FilamentPHP is a lightweight and flexible PHP framework designed for building web applications. It aims to simplify application development by providing a clear structure and high modularity. The framework emphasizes speed, efficiency, and comes with many built-in features that facilitate effective web application development.

Installation

Note
You need to install the filament package first. You can refer to the official site at FilamentPHP

You can install it by running the command below:

composer require hexters/hexa-lite

Then, proceed with the installation of the hexa plugin:

php artisan hexa:install

Install database migrations:

php artisan migrate

Create a superadmin account for admin login:

php artisan hexa:account --create

Plugin Setup

Add the Filament HexaLite plugin to the created panel. If you haven't created one yet, see how to do it here Creating a new panel.

use Filament\Panel;
use Hexters\HexaLite\HexaLite;
 
public function panel(Panel $panel): Panel
{
    return $panel
        ->plugins([
            HexaLite::make(),
        ]);
}

Declaring Access Permissions

Resource & Page

To declare access permissions for Resources and Pages, for Clusters you need to upgrade to the hexters/hexa package.

use Hexters\HexaLite\Traits\HexAccess;

. . .

use HexAccess;

protected static ?string $permissionId = 'access.user';

protected static ?string $descriptionPermission = 'Admin can manage User accounts';

/**
 * Additional permission (optional)
 * You can add it or not depending on the needs of your application.
 */
protected static ?array $subPermissions = [
    'access.user.create' => 'Can Create',
    'access.user.edit' => 'Can Edit',
    'access.user.delete' => 'Can Delete',
];

public static function canAccess(): bool
{
    return hexa()->can(static::$permissionId);
}

. . .

Actions, etc.

You can use the visible() method on several Class Components. For example, let's try it on a button.

Tables\Actions\EditAction::make()
    ->visible(hexa()->can('access.user.edit')),

For giving access to classes extended to Filament\Resources\Pages\EditRecord, Filament\Resources\Pages\CreateRecord, Filament\Resources\Pages\ListRecords, Filament\Resources\Pages\ViewRecords, you can use:

/**
 * @param  array<string, mixed>  $parameters
 */
public static function canAccess(array $parameters = []): bool
{
    return hexa()->can('access.user.edit');
}

Checking Access Permissions

Access can be granted to Resources, Pages, Widgets, Button Actions, etc. The access can be given as shown below.

Using the hexa utility function:

hexa()->can('hexa.admin')

Using Laravel's auth can function:

auth()->user()?->can('hexa.admin')

Using Laravel's Gate class:

use Illuminate\Support\Facades\Gate;

. . .

Gate::allows('hexa.admin')

In a blade template, you can use it as shown below.

<div>
    @can('hexa.admin')
        // Content here ...
    @endcan
</div>

License

This project is licensed under the MIT License - see the LICENSE file for details.

Issue

If you encounter any issues with this plugin, you can submit them to the repository: Filament Hexa Lite Issue

Thank you for using this plugin. We hope it speeds up your process in creating powerful applications.

Happy Coding 🧑‍💻 🧑‍💻 🧑‍💻

Hexters Hexa Lite Related Articles

Manage Roles and Permissions in Filament with Hex Lite image

Manage Roles and Permissions in Filament with Hex Lite

Read article
Laravel Valet Lite image

Laravel Valet Lite

Read article
Eventmie Pro: Multi-Organization Online Event Ticketing Platform image

Eventmie Pro: Multi-Organization Online Event Ticketing Platform

Read article
Build an AI Chat Agent with Laravel 12, MongoDB Atlas Vector Search, and Voyage AI image

Build an AI Chat Agent with Laravel 12, MongoDB Atlas Vector Search, and Voyage AI

Read article
MongoDB Vector Search in Laravel: Finding the Unqueryable image

MongoDB Vector Search in Laravel: Finding the Unqueryable

Read article
Translate Your App to Other Languages With Laravel Gemini Translator image

Translate Your App to Other Languages With Laravel Gemini Translator

Read article

Let your users buy domains without leaving your app

If your Laravel app gives users a site, a storefront, or a workspace, they’ll eventually want their own domain. The name.com API lets them search, register, and connect one without leaving your product. It’s a clean REST API, so Laravel’s HTTP client is all you need.

Let your users buy domains without leaving your app

Acquaint Softtech

Acquaint Softtech offers AI-ready Laravel developers who onboard in 48 hours at $3000/Month with no lengthy sales process and a 100 percent money-back guarantee.

Acquaint Softtech

PhpStorm

The go-to PHP IDE with extensive out-of-the-box support for Laravel and its ecosystem.

PhpStorm

NativePHP

The fastest way to build fully native apps for any platform (with AI or not)

NativePHP

Kirschbaum

Providing innovation and stability to ensure your web application succeeds.

Kirschbaum

Harpoon: Next generation time tracking and invoicing

The next generation time-tracking and billing software that helps your agency plan and forecast a profitable future.

Harpoon: Next generation time tracking and invoicing