I want to filter my results agains multiple DB columns but the way I'm doing it right now doesn't seem Laravel-ish at all :)
Is there a better way? I don't want to pile up all those sql
statements at the end.
$data = Input::except('_token');
if (isset($data['passenger_name']))
{
$passenger_name = $data['passenger_name'];
} else {
$passenger_name = '*';
}
if (isset($data['passenger_lastname']))
{
$passenger_lastname = $data['passenger_lastname'];
} else {
$passenger_lastname = '*';
}
// Run query
$q = Reservation::where('passenger_firstname', 'LIKE', '%'. $passenger_name .'%')
->where('passenger_lastname', 'LIKE', '%' . $passenger_lastname .'%')
->get();
return View::make('dashboard')->with('reservations', $q);
These are just two of many criteria i have to run queries against