Hmm, should match it?
Have you tried a package like: https://github.com/TomLingham/Laravel-Searchy
Hi,
I have this query I'm running Eloquent on my PostgreSQL database:
$searcher = ['filled', 'array', 'list'];
$list = Product::query();
foreach($searcher as $word){
$list->where('title', 'LIKE', '%'.$word.'%');
$list->orWhere('name', 'LIKE', '%'.$word.'%');
}
$list ->orderBy('title')->get();
But I have the problem that for some reason the where Like is case-sensitive.
For example I have this in the Database: "Hello Foobar". If I search for "foobar" it doesn't find it, if I use a capital F it does.
How to fix this?
In general for sql:
foreach($searcher as $word) {
$list->where('LOWER(title)', 'LIKE', '%' . strtolower($word) . '%');
$list->orWhere('LOWER(name)', 'LIKE', '%' . strtolower($word) . '%');
}
or with postgres you should be able to just change your 'LIKE' to 'ILIKE' (case insensitive like) -- it's important to know that ILIKE is not universally supported though.
Please or to participate in this conversation.