-
Notifications
You must be signed in to change notification settings - Fork 220
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
Assign Permissions for pivot model #149
Comments
I thought I was really close to solving the same issue tonight, but I get the following error when I try to save the person's team roles. [07:19:01] LOG.error: Argument 1 passed to Vyuldashev\NovaPermission\RoleBooleanGroup::Vyuldashev\NovaPermission{closure}() must be an instance of Illuminate\Support\Collection, null given {"userId":2,"exception":{}} The way I got the team role selection to show up on both sides of the relationship was to create a class and then add it on both BelongsToMany() calls. On the Account resource: BelongsToMany::make('People')->fields(new AccountPersonFields) |
Hi @annis-souames can you please share with us the codebase of (user_team) and (user) model. |
I made it work (at least saving and updating) using the following code (includes PHP 8 features): RoleSelect::make('Role', 'roles', function (?Collection $roles) {
return $roles?->first()?->name;
}), If you add this on both the Team and User resource it will show you the Role field in the BelongsToMany relationship table when viewing the resource in detail. |
I need to assign different permissions for users based on their teams (a user can join several teams, so he can have different permissions in each team).
In order to achieve this app wise, I created a Pivot Model TeamUser and added the HasRole trait, I also edited the User Model according to this, so permissions are assigned by Spatie package for user-team association.
However I need to assign these permissions on nova too (basically it should be added as a fiekd for the BelongToMany nova relation field) but I have no idea on how to achieve this.
The text was updated successfully, but these errors were encountered: