PHP code example of mmerlijn / nova-checkboxes-field

1. Go to this page and download the library: Download mmerlijn/nova-checkboxes-field 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/ */

    

mmerlijn / nova-checkboxes-field example snippets


use \mmerlijn\NovaCheckboxesField\Checkboxes;

Checkboxes::make('Roles')->options([
    1 => 'Admin',
    2=> 'Super user',
]);

Checkboxes::make('Permissions')->options([
    1 => 'Access Admin UI',
    2 => 'Manage Users',
])->withoutTypeCasting(),

Checkboxes::make('users')
    ->options(App\User::pluck('name', 'id'))
    ->withoutTypeCasting(),

Checkboxes::make('Permissions','permissionArray') 
    ->options(Permission::pluck('name', 'id')->toArray())
    ->hideFromIndex(),

public function setPermissionArrayAttribute(array $value)
{
    $this->permissions()->sync($value);
}
public function getPermissionArrayAttribute()
{
    return $this->permissions->map(fn($item) => $item->pivot->permission_id)->toArray();
}