PHP code example of tiagolemosneitzke / filamentacl

1. Go to this page and download the library: Download tiagolemosneitzke/filamentacl 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/ */

    

tiagolemosneitzke / filamentacl example snippets


use Spatie\Permission\Traits\HasRoles;

class User extends Authenticatable
{
    use HasRoles;
}

use TiagoLemosNeitzke\FilamentAcl\FilamentAclPlugin;
 
public function panel(Panel $panel): Panel
{
    return $panel
        ->plugins([
             FilamentAclPlugin::make()
        ]);
}

return [
    'permission' => [
        'prefixes' => [
            'view',
            'view_any',
            'create',
            'update',
            'restore',
            'delete',
            'force_delete'
        ]
    ],

    'roles_prefixes' => [
        'admin',
    ]
];

use TiagoLemosNeitzke\FilamentAcl\Models\Role;

public static function form(Form $form): Form
    {
        return $form
            ->schema([
                Forms\Components\Select::make('roles')
                    ->label('Role')
                    ->relationship('roles', 'name')
                    ->options(Role::all()->pluck('name', 'id'))
                    ->multiple()
                    ->preload()
                    ->searchable(),
            ]);
    }

    public static function table(Table $table): Table
    {
        return $table
            ->columns([
                Tables\Columns\TextColumn::make('roles.name')
                    ->label('Is Admin?')
                    ->badge(),
             ]);
    }
bash
php artisan vendor:publish --provider="Spatie\Permission\PermissionServiceProvider"
bash
php artisan migrate
bash
php artisan filament-acl:install
bash
php artisan vendor:publish --tag="filament-acl-config"
bash
php artisan vendor:publish --provider="TiagoLemosNeitzke\FilamentAcl\FilamentAclServiceProvider"
bash
php artisan vendor:publish --tag=filament-acl-config
php artisan vendor:publish --tag=filament-acl-stubs