D
D
Dmitry Vyalkov2017-08-31 23:23:45
Laravel
Dmitry Vyalkov, 2017-08-31 23:23:45

How to make a selection from tables in Laravel that are not directly related to each other?

So. The point is the following.
There are 4 tables
courses, lessons, messages, teachers
They are related as follows:
Lessons with messages are related as one to many (one lesson can have many messages)
Courses with lessons are related as one to many (a course has many lessons)
Teachers are related to Many-to-many courses (teachers can have many courses, and a course can have many teachers)
. there is still a lot of other garbage, I think the description above is enough.
Tell me how I can get all the comments from the lessons of a particular teacher as correctly as possible through Eloquent.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Voll., 2017-09-01
@DmitryVyalkov

hasManyThrough

V
vism, 2017-09-01
@vism

show a code example of how you tried to implement it and we will tell you what to do next

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question