mirror of
https://github.com/flarum/framework.git
synced 2024-11-28 20:16:08 +08:00
Fix index sorting
This commit is contained in:
parent
9fd935285f
commit
a19b40e51c
|
@ -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