diff --git a/src/Illuminate/Pagination/LengthAwarePaginator.php b/src/Illuminate/Pagination/LengthAwarePaginator.php index 8d3e0ab77fbe..119f7a14c23d 100644 --- a/src/Illuminate/Pagination/LengthAwarePaginator.php +++ b/src/Illuminate/Pagination/LengthAwarePaginator.php @@ -162,6 +162,16 @@ public function hasMorePages() return $this->currentPage() < $this->lastPage(); } + /** + * Get the next page. + * + * @return int|null + */ + public function nextPage(): ?int + { + return $this->hasMorePages() ? $this->currentPage() + 1 : null; + } + /** * Get the URL for the next page. * @@ -199,6 +209,7 @@ public function toArray() 'last_page' => $this->lastPage(), 'last_page_url' => $this->url($this->lastPage()), 'links' => $this->linkCollection()->toArray(), + 'next_page' => $this->nextPage(), 'next_page_url' => $this->nextPageUrl(), 'path' => $this->path(), 'per_page' => $this->perPage(),