Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

rykr's avatar
Level 1

Help with relations through a mapping table

I have 3 tables. Users, Teams, and TeamMemberships. The team memberships table indicates what users are active members of what teams. The users and teams tables are standard tables with "id" keys.

The team_memberships table looks like this: id user_id team_id joined left

What I want is to have a relation on my Team model that will show all the active members of the team.

I've tried belongsToMany and everything else I can think of but I keep hitting a wall.

Any help appreciated. Thanks

0 likes
0 replies

Please or to participate in this conversation.