assuming team_members table is something like...
id
user_id
team_id
// User model
public function teamMembers()
{
return $this->hasMany(TeamMember::class);
}
// Team model
public function teamMembers()
{
return $this->hasMany(TeamMember::class);
}
// TeamMember model
public function team()
{
return $this->belongsTo(Team::class);
}
public function user()
{
return $this->belongsTo(User::class);
}
@w1n78 thank you for your help. In the TeamMember model, are we (in your code) creating a one-to-one relationship? Because a user can be in multiple teams (or that's the goal).
And, yes, you are correct. The team_members table has:
i'm running through your model in my head but something seems to be missing or can be handled differently. although it's late here and i had some beer earlier haha. hope i'm not steering you in the wrong direction. but generally that's how i handle pivoting
Hi @w1n78 you're suggestions sure seems to work. I'm getting the results that I'm looking for - so I think you've done a great job. Maybe it's a magical make-you-better beer?!