Support the ongoing development of Laravel.io →
posted 11 years ago
Eloquent

Please help me make this query in eloquent. A business can have many categories.

Select b.* from businesses b inner join categorybusiness cb on b.id = cb.business_id inner join category c on cb.category_id = c.id where b.location like '%query1%' and b.location like '%query2%' and c.name like '%query3%' and c.name like '%query4%'.

my tables are.. businesses - contain the location column and a pivot table for category and business..

Last updated 3 years ago.
0

Sign in to participate in this thread!

PHPverse

Your banner here too?

kyriesss kyriesss Joined 9 Feb 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.