mirror of
https://github.com/flarum/core.git
synced 2025-06-04 21:55:04 +02:00
Fix up API default sort order
This commit is contained in:
parent
c8c7d94211
commit
73d6b17963
@ -104,6 +104,11 @@ abstract class Base extends Controller
|
||||
protected function sort($options)
|
||||
{
|
||||
$criteria = (string) $this->input('sort', '');
|
||||
|
||||
if (! in_array($criteria, $options)) {
|
||||
$criteria = reset($options);
|
||||
}
|
||||
|
||||
$order = $criteria ? 'asc' : null;
|
||||
|
||||
if ($criteria && $criteria[0] == '-') {
|
||||
@ -111,10 +116,6 @@ abstract class Base extends Controller
|
||||
$criteria = substr($criteria, 1);
|
||||
}
|
||||
|
||||
if (! in_array($criteria, $options)) {
|
||||
$criteria = reset($options);
|
||||
}
|
||||
|
||||
return [
|
||||
'by' => $criteria,
|
||||
'order' => $order,
|
||||
|
Loading…
x
Reference in New Issue
Block a user