Fix index sorting

This commit is contained in:
Toby Zerner 2015-02-08 15:57:41 +10:30
parent 64270fd066
commit 077975fb17

View File

@ -104,16 +104,19 @@ abstract class Base extends Controller
protected function sort($options)
{
$criteria = (string) $this->input('sort', '');
$order = null;
if ($criteria && $criteria[0] == '-') {
$order = 'desc';
$criteria = substr($criteria, 1);
}
if (! in_array($criteria, $options)) {
$criteria = reset($options);
}
$order = $criteria ? 'asc' : null;
if ($criteria && $criteria[0] == '-') {
$order = 'desc';
$criteria = substr($criteria, 1);
if ($criteria && ! $order) {
$order = 'asc';
}
return [