almost 5 years ago
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
$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
Starting with Chrome version 45, NPAPI is no longer supported for Google Chrome. For more information, see Chrome and NPAPI (blog.chromium.org).
Firefox and Microsoft Internet Explorer are recommended browsers for websites using java applets.
Chrome Version Support
Are you sure, you want to delete this comment?
Terms of Service
| © copyright 2020 FindNerd.com. All rights reserved.
Sign up using