Skip to content

Commit

Permalink
Remove orderable collection requirement
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonvarga committed Oct 5, 2023
1 parent 72527a3 commit c6de64d
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/Tags/Collection/Entries.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,9 @@ public function next($currentEntry)
$operator = '<';
}

if ($collection->orderable() && $primaryOrderBy->sort === 'order') {
$query = $this->query()->where('order', $operator ?? '>', $currentEntry->order());
if ($primaryOrderBy->sort === 'order') {
throw_if(! $currentOrder = $currentEntry->order(), new \Exception('Current entry does not have an order'));
$query = $this->query()->where('order', $operator ?? '>', $currentOrder);
} elseif ($collection->dated() && $primaryOrderBy->sort === 'date') {
$query = $this->query()->where('date', $operator ?? '>', $currentEntry->date());
} else {
Expand All @@ -97,8 +98,9 @@ public function previous($currentEntry)
$operator = '>';
}

if ($collection->orderable() && $primaryOrderBy->sort === 'order') {
$query = $this->query()->where('order', $operator ?? '<', $currentEntry->order());
if ($primaryOrderBy->sort === 'order') {
throw_if(! $currentOrder = $currentEntry->order(), new \Exception('Current entry does not have an order'));
$query = $this->query()->where('order', $operator ?? '<', $currentOrder);
} elseif ($collection->dated() && $primaryOrderBy->sort === 'date') {
$query = $this->query()->where('date', $operator ?? '<', $currentEntry->date());
} else {
Expand Down

0 comments on commit c6de64d

Please sign in to comment.