I'm trying to build search functionality for a reality website. I want to be able to search by multiple parameters at a time, similar to what you would see on almost any retail website. I'm using Laravel on my project and I want to be able to make use of the Query Builder so I can use it's built in pagination.
If I try something like:
$listing = DB::select('select * from listings where city = 'Chicago');
I can't paginate the results.
The other approach would be to do this:
$listing = DB::table('listings')->where('city', 'Chicago')->get();
But the problem is that I don't know how many parameters a user might enter into the search. So how would I build a function call that could look like:
$listing = DB::table('listings')->where('city', 'Chicago')->where('askingPrice', '>', 50000)->where('bedrooms', '>', 3)->get();