#how to get a filtered results in many to many with one to many relationships.

2 messages · Page 1 of 1 (latest)

opal kite
#

Sorry for my bad English

Situation: I have 3 tables class, courses, and subjects.

Class has attributes (Id,name) and has a relation many to many with courses because many class can have the same courses
So, I created a pivot table named

class_course which contain (id, class_id, course_id)

Courses : (id, name)

Courses has a one to many relation with subjects.

I want to filter subject by class for get all subjects for a specific class in a specific courses.

Thank you.

empty gyro
#

You can use a nested whereHas or join the 3 tables.