Answer the question
In order to leave comments, you need to log in
How to make in laravel style Many to Many to one table?
I don’t want to make a raw request, I’m sure Laravel has a beautiful solution for everything. From table A, select fields from table B with foreign keys A1_id A2_id, that is, join A1 and A2 (preferably with a choice of fields and AS to call beautifully)
SELECT con.type1_id, con.type2_id, com1.name AS types, com2.name AS types
FROM types_rel AS con
LEFT JOIN types AS com1 ON (com1.id=con.type1_id)
LEFT JOIN types AS com2 ON (com2.id=con.type2_id)
Answer the question
In order to leave comments, you need to log in
belongsToMany
in the documentation under Eloquent ORM there is a heading even Many To Many
laravel.com/docs/5.1/eloquent-relationships#many-t...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question