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

cpqm07's avatar

Eloquent Relationship Pivot Table with 3 Model

Hi comunity... i'm a little confused, i need to implements a user role according to an trade unions that the user belongs. The user can belongs to a lot of trade unions but his role can be different.

The migrations will be:

users

  • id
  • name

roles -id -name

tradeunions -id -name

user_rol_trade

  • user_id
  • role_id
  • trade_id

What would be the best way to do it? I've worked with pivot table with two models, but with three, I'm a bit confused Thanks a lot !

0 likes
0 replies

Please or to participate in this conversation.