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

ynoth25's avatar

Laravel Eloquent Relationship

I have this table / models:

lesson table and teacher table with pivot lesson_teacher table.

Then I have this registration table, with fields id, student_id, lesson_teacher_id.
And lastly, I have this student table

My question is what is the best way to query the relationships above.

0 likes
3 replies
MohamedTammam's avatar

What exactly do you want to query? what data do you want to retrieve?

ynoth25's avatar

@MohamedTammam, I wanted to get the details of teachers, students and lessons using the registration table with fields lesson_teacher_id (Pivot table contains teacher and lesson id), student_id and etc.

Please or to participate in this conversation.