Skip to content

Traits Reference

TraitUsed onPurpose
HexaRolePermissionThe Authenticatable (User) modelProvides the roles() relationship, guard-scoped.
HasHexaRoleResources, Pages, Widgets, ClustersDeclares gates via defineGates() and related meta.
UuidGeneratorModels with a uuid columnAuto-generates a UUID and uses it as the route key.
UlidGeneratorModels with a ulid columnAuto-generates a ULID and uses it as the route key.

HexaRolePermission

Add to your User model. Exposes the roles() many-to-many relationship, filtered by the active guard.

php
use Hexters\Hexa\HexaRolePermission;

class User extends Authenticatable
{
    use HexaRolePermission;
}

HasHexaRole

Add to any component that should contribute permissions.

php
use Hexters\Hexa\HasHexaRole;

class UserResource extends Resource
{
    use HasHexaRole;

    public function defineGates(): array
    {
        return ['user.index' => __('View users')];
    }
}

Optional methods: roleName(), roleDescription(), defineGateDescriptions(), and the $hexaSort property — see Descriptions & Order.

Released under the MIT License.