Skip to content

Tag: eloquent

find() does not get the existing row

I have a resource Controller with this index method like this: But it returns this error: Trying to get property ‘slug’ of non-object And when I dd(Category::find(25), Category::find(24), Category::find(23), Category::find(22)); I get NULL results. Meaning that it can not find data with specified …

Eloquent “where” on relationship returns wrong models

I have this method on my model “Employer”: 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? Answer I think yo…