Support the ongoing development of Laravel.io →
posted 10 years ago
Eloquent
Last updated 2 years ago.
0
Solution

Try this :)

$query = User::query();
$keys = ['key1','key2','key3'];
foreach($keys as $key)
{
    $query->where('search','LIKE','%'.$key.'%');

}
$query->take(5);
echo $query->toSql();

output:

select * from `users` where `search` LIKE ? and `search` LIKE ? and `search` LIKE ? limit 5
Last updated 2 years ago.
0

This works great ! Thank you =D

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

AoEmaster aoemaster Joined 15 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.

© 2024 Laravel.io - All rights reserved.