Skip to content

Commit

Permalink
Add nextPage() method to LengthAwarePaginator.
Browse files Browse the repository at this point in the history
  • Loading branch information
hossein-zare authored Oct 26, 2024
1 parent 000272b commit f38d305
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/Illuminate/Pagination/LengthAwarePaginator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down Expand Up @@ -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(),
Expand Down

0 comments on commit f38d305

Please sign in to comment.