PHP code example of idez / nova-checkboxes-field
1. Go to this page and download the library: Download idez/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/ */
idez / nova-checkboxes-field example snippets
use Idez\NovaCheckboxesField\Checkboxes;
use Laravel\Nova\Http\Requests\NovaRequest;
class CustomResource extends Resource
{
public function fields(NovaRequest $request): array
{
$permissions = [
'user.list' => 'List users',
'user.create' => 'Create user',
'user.edit' => 'Edit users',
'user.delete' => 'Delete users',
'post.list' => 'List posts',
'post.create' => 'Create posts',
'post.edit' => 'Edit posts',
'post.delete' => 'Delete posts',
];
return [
Checkboxes::make('Permissions', 'permissions')
->options($permissions),
];
}
}
use Idez\NovaCheckboxesField\Checkboxes;
use Laravel\Nova\Http\Requests\NovaRequest;
class CustomResource extends Resource
{
public function fields(NovaRequest $request): array
{
$permissions = [
'Users' => [
'user.list' => 'List users',
'user.create' => 'Create user',
'user.edit' => 'Edit users',
'user.delete' => 'Delete users',
],
'Posts' => [
'post.list' => 'List posts',
'post.create' => 'Create posts',
'post.edit' => 'Edit posts',
'post.delete' => 'Delete posts',
],
];
return [
Checkboxes::make('Permissions', 'permissions')
->options($permissions)
->withGroups(),
];
}
}