From c6de64d020b9815a379137069ef7ce2ccbeffede Mon Sep 17 00:00:00 2001 From: Jason Varga Date: Thu, 5 Oct 2023 11:21:47 -0400 Subject: [PATCH] Remove orderable collection requirement --- src/Tags/Collection/Entries.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Tags/Collection/Entries.php b/src/Tags/Collection/Entries.php index 562a6287e3..85bd7c5603 100644 --- a/src/Tags/Collection/Entries.php +++ b/src/Tags/Collection/Entries.php @@ -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 { @@ -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 {