nionta
194
9
Laravel

Like search is not working properly in Eloquent

Posted 1 month ago by nionta

here is my query:

    ->when(!empty($name), function($query) use ($name){
                return $query->where('infos.name', 'like', $name.'%')
                    ->orWhere('infos.name', 'like', '% '.$name.'%');
            })

but, its not working for finding 2nd or last word of a name; as,in "Mohoshin Ara Tahera", if I search "Mohoshin" it works, but if I search "Ara" or "Tahera" or "Mohoshin Ara" it's not showing any result.

Please sign in or create an account to participate in this conversation.

Reply to

Use Markdown with GitHub-flavored code blocks.