From cc212b3254cd8a7d9146bd8f87f8e925ee73858e Mon Sep 17 00:00:00 2001 From: Ryan Cramer Date: Wed, 21 Nov 2018 10:49:53 -0500 Subject: [PATCH] Add hasNext() and hasPrev() methods to PaginatedArray class --- wire/core/PaginatedArray.php | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/wire/core/PaginatedArray.php b/wire/core/PaginatedArray.php index cdefdc6a..910275f0 100644 --- a/wire/core/PaginatedArray.php +++ b/wire/core/PaginatedArray.php @@ -138,6 +138,30 @@ class PaginatedArray extends WireArray implements WirePaginatable { return $this->numStart; } + /** + * Is there a next pagination containing more items in this PaginatedArray after the current one? + * + * #pw-group-other + * + * @return int + * + */ + public function hasNext() { + return $this->getStart() + $this->count() < $this->getTotal(); + } + + /** + * Is there a previous pagination before the current one? + * + * #pw-group-other + * + * @return bool + * + */ + public function hasPrev() { + return $this->getStart() > 0; + } + /** * Get a property of the PageArray *