Typhon
Roles on pivot table
What I am trying to do:
Roles are handled by spatie/laravel-permission.
I have two models with different roles in my project. One is User and one is OrganisationUser (pivot table between the User & Organisation). I want to show and edit this role in the relationship manager that I made for the OrganisationResource.
What I did:
I tried to make a text column with the name 'pivot.roles.name' because just 'roles.name' works for the UserResource. Eventually I made an attribute called rolesNames in OrgansationUser by doing 'pivot.rolesNames' I am able to show roles correct in the relationshipmanager. But this does not fix editing roles.
My issue/the error:
I can't seem to edit roles in the relationship manager. If I make a select the same way I did in the UserResource, it takes the roles from user. I want it to take the roles from the pivot table (OrgansationUser).
Code:
UsersRelationshipManager.php
OrganisationUser.php
8 replies