mirror of
https://github.com/flarum/framework.git
synced 2024-11-23 01:51:05 +08:00
Fix index sorting
This commit is contained in:
parent
64270fd066
commit
077975fb17
|
@ -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 [
|
||||
|
|
Loading…
Reference in New Issue
Block a user