PHP code example of althinect / filament-spatie-roles-permissions

1. Go to this page and download the library: Download althinect/filament-spatie-roles-permissions 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/ */

    

althinect / filament-spatie-roles-permissions example snippets


php artisan vendor:publish --tag="filament-spatie-roles-permissions-config" --force

use Althinect\FilamentSpatieRolesPermissions\FilamentSpatieRolesPermissionsPlugin;

$panel
    ...
    ->plugin(FilamentSpatieRolesPermissionsPlugin::make())


return $form->schema([
    Select::make('roles')->multiple()->relationship('roles', 'name')
])

use Althinect\FilamentSpatieRolesPermissions\Concerns\HasSuperAdmin;

class User extends Authenticatable{

...
use HasSuperAdmin;

Gate::before(function (User $user, string $ability) {
    return $user->isSuperAdmin() ? true: null;     
});


'guards' => [
    ...

    'api' => [
        'driver' => 'token',
        'provider' => 'users',
        'hash' => false,
    ],
],

'teams' => true

...
public function team(): BelongsTo
{
    return $this->belongsTo(Team::class);
}

use Althinect\FilamentSpatieRolesPermissions\Middleware\SyncSpatiePermissionsWithFilamentTenants;

$panel
    ...
    ->tenantMiddleware([
        SyncSpatiePermissionsWithFilamentTenants::class,
    ], isPersistent: true)
bash
php artisan vendor:publish --provider="Spatie\Permission\PermissionServiceProvider"
bash
php artisan vendor:publish --tag="filament-spatie-roles-permissions-config" --force
bash
php artisan vendor:publish --tag="filament-spatie-roles-permissions-translations"
bash
php artisan permissions:sync
bash
php artisan permissions:sync -C|--clean
bash
php artisan permissions:sync -P|--policies
bash
php artisan permissions:sync -O|--oep
bash
php artisan permissions:sync -COPY