vyuldashev / nova-permission

A Laravel Nova tool for Spatie's laravel-permission library
https://novapackages.com/packages/vyuldashev/nova-permission
419 stars 217 forks source link

2.4.1 BooleanGroup error when creating a role #109

Closed jwktje closed 4 years ago

jwktje commented 4 years ago

Fresh install gives me this error on creating a role

{
    "message": "Class 'Laravel\\Nova\\Fields\\BooleanGroup' not found",
    "exception": "Symfony\\Component\\Debug\\Exception\\FatalErrorException",
    "file": "/vendor/vyuldashev/nova-permission/src/PermissionBooleanGroup.php",
    "line": 12,
    "trace": []
}
jwktje commented 4 years ago

I figured out this was because of an outdated Nova version.

Follow up question before you close this issue;

Is there a way to display RoleBooleanGroup in the list by default without having to click "View"?

What I ideally would want is :

pzmarzly commented 4 years ago

Is there a way to display RoleBooleanGroup in the list by default without having to click "View"?

What I ideally would want is :

* Have one role per user

* Show that role directly in the index view of the Users

Try putting this in your fields() method:

RoleBooleanGroup::make(__('Roles'), 'roles')->hideFromIndex(),
Text::make(__('Role'), function () {
    return $this->roles->map->name->join(', ');
})->onlyOnIndex(),

Reference: https://nova.laravel.com/docs/2.0/resources/fields.html#computed-fields