Open sanderbaas opened 1 year ago
@sanderbaas @leandrogehlen
You can try adding custom resolver to your permissions field:
Checkboxes::make(__('Permissions'), 'permissions')
->options($this->loadPermissions()->map(function ($permission) {
return [
'group' => $this->translatePermissions(ucfirst($permission->group)),
'option' => $permission->name,
'label' => $this->translatePermissions($permission->name),
];
})
->groupBy('group')
->toArray()
)
->resolveUsing(function ($value) use ($request) {
if ($request->get('fromResourceId')) {
return \Sereny\NovaPermissions\Models\Role::find($request->get('fromResourceId'))->permissions->pluck('name')->toArray();
}
return $value->pluck('name')->toArray();
}),
Thanks for the suggestion.
Can you make a PR to solve this issue?
Please check if is there some more elegant way instead of $request->get('fromResourceId')
I am using version 1.3.1 on Nova 4.22.1.
When replicating a role, none of the permissions are checked.