Support the ongoing development of Laravel.io →
posted 10 years ago
Eloquent
Last updated 2 years ago.
0

Well that's not a basic many to many relationship. What you have is:

A->C: One to many

B->C: One to many

D->C: One (or many) to many.

Last updated 10 years ago.
0

You need to create a model for the pivot table (not (only) pivot model).

Read this http://stackoverflow.com/a/24585837/784588

You can alternatively consider different approach - pivot table between three tables with this https://github.com/jarektkaczyk/Eloquent-triple-pivot. That depends on your needs.

Last updated 10 years ago.
0

Yes, it works :D

What I've looking for is:

$material = Material::with('elements', 'elementMaterials.otherModels')->first();

for querying relationship since I've already got pivot model.

Thanks for all the replies!

Last updated 10 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

rudwna rudwna Joined 28 Dec 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.