I'm not sure if this is the culprit, but I think you have an unnecessary space in your query -
->orWhere('infos.name', 'like', '% '.$name.'%');
Should be...
->orWhere('infos.name', 'like', '%'.$name.'%');
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 or to participate in this conversation.