Skip to content

Commit

Permalink
Determine first and last resource correctly for customised sort queries.
Browse files Browse the repository at this point in the history
  • Loading branch information
morphsteve authored Sep 20, 2018
1 parent 6f365a5 commit e9be981
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/OrderField.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,8 @@ class OrderField extends Field
*/
protected function resolveAttribute($resource, $attribute)
{
$orderField = $resource->sortable['order_column_name'];

$first = $resource->newQuery()->orderBy($orderField, 'asc')->first();
$last = $resource->newQuery()->orderBy($orderField, 'desc')->first();
$first = $resource->buildSortQuery()->ordered()->first();
$last = $resource->buildSortQuery()->ordered('desc')->first();

$this->withMeta([
'first' => is_null($first) ? null : $first->id,
Expand Down

0 comments on commit e9be981

Please sign in to comment.