You mean Many to Many? Make pivots that join things together then group them all in one query line like
Factor::with('role', 'movie')->where...etc etc
http://laravel.com/docs/4.2/eloquent#many-to-many-polymorphic-relations
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hi, I am know to Laravel word and programming.
Joining 2 tables is easy with hasMany relation.But how can I Join 3 tables? Say that, in my mind there is a simple app about movies. A movie has a few Factors and each Factor has a Role in the Movie.
So 3 Models = 3 tables 1.Movie = movies 2.Factor = factors 3.Role =roles
And the table will join the factor_movie_role*(1) with 3 col factor_id, movie_id, role_id
why I think it like that? Because a factor(Jefry Way) is the role(director) of movie(Need more?:Laracasts) but also is the role(storyteller).
(1) wich is the best practice for naming a pivot table like this
Please or to participate in this conversation.