mirror of
https://github.com/flarum/core.git
synced 2025-10-27 21:46:17 +01:00
Update discussion/post sort semantics inline with new API actions
Instead of $sort and $order being separate, they are now a single array, allowing multiple sort criteria: `[‘foo’ => ‘asc', ‘bar’ => ‘desc’]`
This commit is contained in:
@@ -29,19 +29,21 @@ class EloquentPostRepository implements PostRepositoryInterface
|
||||
*
|
||||
* @param array $where
|
||||
* @param \Flarum\Core\Models\User|null $user
|
||||
* @param string $sort
|
||||
* @param string $order
|
||||
* @param array $sort
|
||||
* @param integer $count
|
||||
* @param integer $start
|
||||
* @return \Illuminate\Database\Eloquent\Collection
|
||||
*/
|
||||
public function findWhere($where = [], User $user = null, $sort = 'time', $order = 'asc', $count = null, $start = 0)
|
||||
public function findWhere($where = [], User $user = null, $sort = [], $count = null, $start = 0)
|
||||
{
|
||||
$query = Post::where($where)
|
||||
->orderBy($sort, $order)
|
||||
->skip($start)
|
||||
->take($count);
|
||||
|
||||
foreach ((array) $sort as $field => $order) {
|
||||
$query->orderBy($field, $order);
|
||||
}
|
||||
|
||||
return $this->scopeVisibleForUser($query, $user)->get();
|
||||
}
|
||||
|
||||
|
||||
@@ -22,13 +22,12 @@ interface PostRepositoryInterface
|
||||
*
|
||||
* @param array $where
|
||||
* @param \Flarum\Core\Models\User|null $user
|
||||
* @param string $sort
|
||||
* @param string $order
|
||||
* @param array $sort
|
||||
* @param integer $count
|
||||
* @param integer $start
|
||||
* @return \Illuminate\Database\Eloquent\Collection
|
||||
*/
|
||||
public function findWhere($where = [], User $user = null, $sort = 'time', $order = 'asc', $count = null, $start = 0);
|
||||
public function findWhere($where = [], User $user = null, $sort = [], $count = null, $start = 0);
|
||||
|
||||
/**
|
||||
* Find posts by their IDs, optionally making sure they are visible to a
|
||||
|
||||
Reference in New Issue
Block a user