I have been writing an API for my mobile application using Laravel 4 & Eloquent. I have read some details about writing a good API including Phil's Build a Decent API & apigee's RESTful API Design.
APIgee talks about sweeping complexity under query strings. Getting parameters from query string can be cumbersome because parameters could vary in number & types. For example to get a dog with black color, the request would be
http://url.com/api/dogs?color=black
And dog with black color & age would be
http://url.com/api/dogs?color=black&age=16
$dogs = new Dog;
if(Input::get('color'))
$houses->where('color', '=', Input::get('color'));
if(Input::get('age'))
$houses->where('age', '=', Input::get('age'));
// Keep adding more for every filter you have :-|
$dogs = $dogs->get();
An alternative & yet a better way was to use DB column names as param names and use a foreach loop to construct a query.
However, I was wondering if there was an alternative to this approach or if this is a standard approach in handling query strings.