Dear friends, below code is working fine in mysql. I want this code to be converted for Laravel so guys please help if anyone.
SELECT * FROM tablename WHERE (field1=1 AND (field2=32 or field3=8) AND (field4 LIKE "%6562%" OR field5 LIKE "%6562%"))
Thanks in advance
I have converted this as below-
$location="8";
$keywords="6562";
$lst = listing::whereRaw('find_in_set(?,country_id)',[$cid])
->where(function ($query) use ($location) {
$query->where('state', $location)->orWhere('city', $location);
})
->where(function ($query) use ($keywords) {
$query->where('title','LIKE', '%'.$keywords.'%')->orWhere('listing_id', 'LIKE', '%'.$keywords.'%');
})
->paginate(20);
but getting blank as result
@AUGUST - $location=$filters['location'];
$keywords=$filters['keywords'];
$lst = listing::whereRaw('find_in_set(?,country_id)',[$cid])
->where(function ($query) use ($location) {
$query->where('state', $location)
->orWhere('city', $location);
})
->where(function ($query) use ($keywords) {
$query->where('title','LIKE', '%'.$keywords.'%')
->orWhere('listing_id', 'LIKE', '%'.$keywords.'%');
})
->paginate(20);
dd($lst);
it returns either title or listing_id or simetimes blank however there is one row.