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

Eiz's avatar
Level 4

Get BelongsToMany and BelongsTo

If I have three tables A, B and C.

B and C have ManyToMany relationships, so there is a pivot table B_C.

Each record of B belongs to one record of A.

I can get B records associated with C from C Model by using belongsToMany relationship.

And I can get A record associated with B from B Model by using belongsTo relationship.

My question is how can I get B records with their associated A records from C Model?

0 likes
0 replies

Please or to participate in this conversation.