Closed emogeekface closed 2 years ago
Hello there! Thanks for opening your first issue on this repo!
Just a heads-up: Here at Backpack we use Github Issues only for tracking bugs. Talk about new features is also acceptable. This helps a lot in keeping our focus on improving Backpack. If you issue is not a bug/feature, please help us out by closing the issue yourself and posting in the appropriate medium (see below). If you're not sure where it fits, it's ok, a community member will probably reply to help you with that.
Backpack communication mediums:
backpack-for-laravel
tag;Please keep in mind Backpack offers no official / paid support. Whatever help you receive here, on Gitter, Slack or Stackoverflow is thanks to our awesome awesome community members, who give up some of their time to help their peers. If you want to join our community, just start pitching in. We take pride in being a welcoming bunch.
Thank you!
-- Justin Case The Backpack Robot
Hey @emogeekface ,
Indeed, this package assumes one user can have multiple roles. If that's not what you want, feel free to customize the UserCrudController to match your needs. But keep in mind users & permissions are both set using ONE field, checklist_dependency
, which connects two sets of checkboxes.
If you want a select and a set of checkboxes, you can do that, but it won't be plug-and-play, you have to code it yourself. There are Backpack components that can help, though:
I'm going to close this issue, as it's not really a bug - it's a custom feature that we don't plan on supporting.
Hope it helps. Cheers!
Bug report
There doesn't seem to be a way to limit users to one role each.
What I did:
I have created my own
UserCrudController.php
andRoles
Model and have changed thechecklist_dependency
fields for roles and permissions within theaddUserFields
function to:What I expected to happen:
I expect to be able to select one role for a user using the select2 dropdown, and successfully create and save the user.
What happened:
I receive the error:
array_values(): Argument #1 ($array) must be of type array, int given
from the linereturn $this->traitStore();
in thestore()
function.What I've already tried to fix it:
This appears to be because roles is being passed across as an integer, and not an array.
I have tried to find out whether this is a backpack or spatie issue and have a feeling it might be due to spatie permissions stating that user has a BelongsToMany relationship with roles, however, I can't figure out how to override that.
Backpack, Laravel, PHP, DB version:
Backpack v5 Laravel v9