I've already posted this on the laravel forums but nobody was able to offer any help. Thought I'd post here for a second opinion.
I need a little advice/help with how to structure my models. Here's what I'm trying to do
A User can be a member of multiple Teams, but the user can fulfill a different Role on each team.
The idea being that the user sees a different set of data/features depending on the role they occupy on the team.
So I had thought about something like:
Users
id, name, email, etc...
Teams
id, name, description
Roles
id, name
Team Users
user_id, team_id, role_id
The team_members
table would tie the 3 pieces together. Defining what teams a user belongs to and the role they have.
My questions are:
- Is this the best way to go about such a relationship
- How would I assign a user to a team with a role?
- Using Eloquent, how would I get a users role on a given team?