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

How can I edit and not remove the role already assigned to a user. #590

Open
sebastianBH12 opened this issue May 17, 2022 · 3 comments
Open

Comments

@sebastianBH12
Copy link

sebastianBH12 commented May 17, 2022

I need that when editing the information of a user I can also edit the currently assigned role

@JosephSilber
Copy link
Owner

Can you provide more information?

  1. What are you trying to do?
  2. How are you currently trying to do it?
  3. What would you expect the outcome to be?
  4. What happens instead?

@sebastianBH12
Copy link
Author

  1. What are you trying to do?

I want to edit an existing user's assigned role

  1. How are you currently trying to do it?

$user->update([
'name'=>request('name') ,
'email'=>request('email')
]);
Bouncer::sync($user)->roles([]);
$role= $request->input('role');
$user->assign($role);

return redirect()->route('users.show', $user);

I take the role selected in the form, remove the previous one and assign a new one

  1. What would you expect the result to be?

that the record in roles_assigned is edited and does not generate a new one

  1. What happens instead?

instead remove the role and create a new one, the idea is to edit the record in the roles_assigned table

Thank you very much for your attention.

@JosephSilber
Copy link
Owner

Why would you want the record in roles_assigned to be updated instead of simply being replaced? What difference does it make?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants