I have a situation where we have to make query for searching on the basis of multiple fields with Laravel 4.x. So for this we have many method either we will concatenate or we will use OR query in Laravel
Example:
$searchqueryResult =User::where('fname', 'LIKE', '%'.$search.'%')->orWhere('lname','LIKE', '%'.$search.'%')->orWhere('location','LIKE', '%'.$search.'%')->orWhere('summary','LIKE', '%'.$search.'%')->orWhere('headline','LIKE', '%'.$search.'%')->where('id','<>',$user_id)->where('userstatus','=','approved')->orderBy('karmascore','DESC')->get();
Here we can see that we have to search on the basis of (first name,last name,location,summary). By using this
query we will solve this problem. We can also use concatenate to solve this problem.
Note:Here User is a eloquent and that query is in laravel 4.x
0 Comment(s)