quick icon indicating copy to clipboard operation
quick copied to clipboard

whereHas with a hasManyThrough returns everything

Open MordantWastrel opened this issue 4 years ago • 0 comments

Will provide more detail later but wanted to get this down before heading into a meeting.

We have qChild registrations() (hasmany) --> qRegistration teamAssignments() (hasmany) --> qPlayerAssignment

We also have qChild teamAssignments() (hasManyThrough) [ "registrations", "teamAssignments" ]

If on qChild I ask for whereHas( "registrations.teamAssignments", ( constraints) ); it will work as desired.

If I ask for whereHas( "teamAssignments" ) then it returns every child with any qPlayerAssignment, regardless of whether they have an intermediate registration based on the constraints I add.

In other words -- exactly the same whereHas called on a hasManyThrough() produces different results than if you call it on hasMany() using dot notation when it seems like these ought to be identical.

MordantWastrel avatar Sep 01 '20 15:09 MordantWastrel