Skip to content
Advertisement

Eloquent “where” on relationship returns wrong models

I have this method on my model “Employer”:

JavaScript

I thought it would work fine, but it ends up giving me models that aren’t even related to my Model. Like, the id of the model is 37 and it gives me the relationships of all the models (like id 6).

Any idea of why this would happen?

Advertisement

Answer

I think you are experiencing unexpected behaviour due to not grouping the where and orWhere in the same call. Does this work?

JavaScript
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement