Answer the question
In order to leave comments, you need to log in
How to get a model that has a model that has foo like bar?
Hello.
Need to find a device that has an attribute that has foo like "bar"
Example in SQL:
device n:m attribute
select device.id from device where device.id in
(select device_id from device_attribute where attribute_id in
(select attribute.id from attribute where attribute.foo like "bar")
)
$attr = Attribute::where('foo', 'like', 'bar')->first();
$device = $attr->device()->first();
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question