Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replicating role does not replicate checked permissions #19

Open
sanderbaas opened this issue Jun 16, 2023 · 2 comments
Open

Replicating role does not replicate checked permissions #19

sanderbaas opened this issue Jun 16, 2023 · 2 comments
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@sanderbaas
Copy link

I am using version 1.3.1 on Nova 4.22.1.

When replicating a role, none of the permissions are checked.

@leandrogehlen leandrogehlen added the bug Something isn't working label Jun 16, 2023
@leandrogehlen leandrogehlen added the help wanted Extra attention is needed label Sep 25, 2023
@Rokasl
Copy link

Rokasl commented Mar 19, 2024

@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();
                }),

@leandrogehlen
Copy link
Contributor

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')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants