Level 54
what's the value of sortBy? Is it passing in the column to sort by? just a boolean? what?
You should probably either have it pass in the column (maybe not the most secure option), or determine the column before building the query.. in either case you could then just do something like this:
$direction = 'DESC';
$column = 'saleDate';
if (Request::get('sortBy')) {
$column = 'trader_id';
}
$data = table('foo')
->orderBy($column, $direction)
->get();
1 like