I've got a set-up where users can join groups and have a role in that group. I have three tables:
users, group_roles, groups
I have a ManyToMany relationship between the users and groups, because many users can be part of many groups, and groups can have many users.
The group_roles table defines role types, like "admin," "owner," "member," and the pivot table for users<->groups ("group_user") includes the "role" integer field, which references a record in group_roles.
I've got the users<->groups pivot working fine. What do I need to do to do something like this:
$users = User::find(auth()->id()); // get current user
$groups = $users->groups; // grab the groups he is a member of
// how do I get the name of the role, and not just the id?
I'm just not sure what the common approach is for this. I checked eloquent-relationships in the docs. Is it "Has Many Through?"
Anyway, I'm stuck. If anybody has clues or links, I'd be grateful.