From 63900f4788bdbcfb02afb4ee11b530a6bcd7f0de Mon Sep 17 00:00:00 2001 From: Andrea Marco Sartori Date: Thu, 11 Jan 2024 20:56:54 +1000 Subject: [PATCH] Implement total pages aware pagination --- src/Paginations/TotalPagesAwarePagination.php | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 src/Paginations/TotalPagesAwarePagination.php diff --git a/src/Paginations/TotalPagesAwarePagination.php b/src/Paginations/TotalPagesAwarePagination.php new file mode 100644 index 0000000..57c0896 --- /dev/null +++ b/src/Paginations/TotalPagesAwarePagination.php @@ -0,0 +1,35 @@ +config->totalPages !== null + && $this->config->perPage === null; + } + + /** + * Yield the paginated items. + * + * @return Traversable + */ + public function getIterator(): Traversable + { + yield from $this->itemsByTotalPages($this->config->totalPages); + } +}