承接 hexters/hexa-lite 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

hexters/hexa-lite

Composer 安装命令:

composer require hexters/hexa-lite

包简介

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

README 文档

README

Latest Stable Version Total Downloads License Documentation

Filament Hexa Lite is a free and developer-friendly role and permission management plugin for FilamentPHP V5.
It helps you manage user roles and access permissions across Resources, Pages, and Widgets — with support for multi-panel apps via custom guards.

Currently in version 3, Hexa Lite is more intuitive, customizable, and production-ready.

Banner

📖 Full documentation: hexters.github.io/hexa-docs

Version Docs.

Version Filament Doc.
V1 V3 Read Doc.
V2 V3 Read Doc.
V3 V5 Read Doc.

Index

Installation

Install the package via Composer:

composer require hexters/hexa-lite

Run the database migration:

php artisan migrate

Register the plugin in your Filament panel:

use Filament\Panel;
use Hexters\HexaLite\HexaLite;

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

Apply the trait to your User model:

use Hexters\HexaLite\HexaLiteRolePermission;

class User extends Authenticatable
{
    use HasFactory, Notifiable;
    use HexaLiteRolePermission;
}

Adding Role Selection

To allow role assignment via the admin panel, add a select input to your UserForm class:

use Filament\Forms\Components\Select;
use Filament\Forms\Components\TextInput;

public static function form(Form $form): Form
{
    return $form
        ->schema([
            TextInput::make('email')
                ->unique(ignoreRecord: true)
                ->required(),

            Select::make('roles')
                ->label(__('Role Name'))
                ->relationship('roles', 'name')
                ->placeholder(__('Superuser')),
        ]);
}

Multi Panel Support

Hexa Lite supports multiple panels, each with its own auth guard.

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

Define permissions using the defineGates() method on Resources, Pages, or Widgets:

use Hexters\HexaLite\HasHexaLite;

class UserResource extends Resource
{
    use HasHexaLite;

    public function defineGates(): array
    {
        return [
            'user.index' => __('Allows viewing the user list'),
            'user.create' => __('Allows creating a new user'),
            'user.update' => __('Allows updating users'),
            'user.delete' => __('Allows deleting users'),
        ];
    }
}

Access Control

Users with no assigned role are treated as Superusers and have full access by default.

To restrict access to a resource:

use Illuminate\Auth\Access\Response;
use Illuminate\Database\Eloquent\Model;

    public static function getViewAnyAuthorizationResponse(): Response
    {
        return hexa()->can('user.index')
            ? Response::allow()
            : Response::deny();
    }

    public static function getCreateAuthorizationResponse(): Response
    {
        return hexa()->can('user.create')
            ? Response::allow()
            : Response::deny(__('You do not have permission to create user.'));
    }

    public static function getEditAuthorizationResponse(Model $record): Response
    {
        return hexa()->can('user.update')
            ? Response::allow()
            : Response::deny(__('You do not have permission to edit this.'));
    }

    public static function getDeleteAuthorizationResponse(Model $record): Response
    {
        return hexa()->can('user.delete')
            ? Response::allow()
            : Response::deny(__('You do not have permission to delete user.'));
    }

    public static function getDeleteAnyAuthorizationResponse(): Response
    {
        return hexa()->can('user.delete')
            ? Response::allow()
            : Response::deny(__('You do not have permission to delete users.'));
    }

Check Permissions in Code

Useful in queued jobs, commands, or background services:

return hexa()->user(User::first())->can('user.index');

Visible Access

Use visible() to conditionally display UI elements:

Actions\CreateAction::make('create')
    ->visible(fn() => hexa()->can(['user.index', 'user.create']));

Laravel Integration

You can still use Laravel’s native authorization:

Auth::user()->can('user.create');

Gate::allows('user.create');

Gate::forUser(User::first())->allows('user.create');

@can('user.create')
    // Blade directive
@endcan

Available Traits

Trait Description
HexaLiteRolePermission Apply to your Authenticatable user model
HasHexaLite Use in Resources, Pages, Widgets, or Clusters
UuidGenerator Use on models with uuid fields
UlidGenerator Use on models with ulid fields

Features in Pro Version

Need more flexibility and control?

Filament Hexa Pro v3 unlocks powerful features designed for serious projects:

  • Role & permission descriptions
  • Custom role sorting
  • Gate grouping (with nested access)
  • Multi-tenancy support
  • Meta option storage

A small investment for a much more capable permission system.

Learn more in the official documentation:
👉 Hexa Pro Documentation

License

This project is open-source and licensed under the MIT License. You are free to use, modify, and distribute it with attribution.

Issues & Feedback

Found a bug or want to contribute?

Open an issue at: https://github.com/hexters/hexa-lite/issues

Thank you for using Filament Hexa Lite!

hexters/hexa-lite 适用场景与选型建议

hexters/hexa-lite 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 11.39k 次下载、GitHub Stars 达 93, 最近一次更新时间为 2024 年 07 月 01 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「Hexa plugin」 「role and permission Filament」 「role management Filament」 「access permissions Filament」 「Hexa Filament」 「hexters ladmin」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 hexters/hexa-lite 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 hexters/hexa-lite 我们能提供哪些服务?
定制开发 / 二次开发

基于 hexters/hexa-lite 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 11.39k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 93
  • 点击次数: 25
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 93
  • Watchers: 1
  • Forks: 13
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-07-01