PHP code example of hexters / hexa-lite

1. Go to this page and download the library: Download hexters/hexa-lite library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

hexters / hexa-lite example snippets


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

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

use Hexters\HexaLite\HexaLiteRolePermission;

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

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

public function panel(Panel $panel): Panel
{
    return $panel->authGuard('reseller');
}

public function panel(Panel $panel): Panel
{
    return $panel->authGuard('customer');
}

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

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

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

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

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

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

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

@can('user.create')
    // Blade directive
@endcan
bash
php artisan migrate