@@ -37,9 +37,16 @@ abstract class Paginator implements Iterator, Countable
3737
3838 /**
3939 * Internal Marker For The Current Page
40+ *
41+ * @deprecated Use $currentPage instead
4042 */
4143 protected int $ page = 1 ;
4244
45+ /**
46+ * Denotes the current page
47+ */
48+ protected int $ currentPage = 0 ;
49+
4350 /**
4451 * When using async this is the total number of pages
4552 */
@@ -169,22 +176,23 @@ public function current(): Response|PromiseInterface
169176 public function next (): void
170177 {
171178 $ this ->page ++;
179+ $ this ->currentPage ++;
172180 }
173181
174182 /**
175183 * Get the key of the paginator
176184 */
177185 public function key (): int
178186 {
179- return $ this ->page - 1 ;
187+ return $ this ->currentPage ;
180188 }
181189
182190 /**
183191 * Check if the paginator has another page to retrieve
184192 */
185193 public function valid (): bool
186194 {
187- if (isset ($ this ->maxPages ) && $ this ->page > $ this ->maxPages ) {
195+ if (isset ($ this ->maxPages ) && ( $ this ->currentPage + 1 ) > $ this ->maxPages ) {
188196 return false ;
189197 }
190198
@@ -193,7 +201,7 @@ public function valid(): bool
193201 }
194202
195203 if ($ this ->isAsyncPaginationEnabled ()) {
196- return $ this ->page <= $ this ->totalPages ??= $ this ->getTotalPages ($ this ->currentResponse );
204+ return ( $ this ->currentPage + 1 ) <= $ this ->totalPages ??= $ this ->getTotalPages ($ this ->currentResponse );
197205 }
198206
199207 return $ this ->isLastPage ($ this ->currentResponse ) === false ;
@@ -204,6 +212,7 @@ public function valid(): bool
204212 */
205213 public function rewind (): void
206214 {
215+ $ this ->currentPage = max (0 , $ this ->startPage - 1 );
207216 $ this ->page = $ this ->startPage ;
208217 $ this ->currentResponse = null ;
209218 $ this ->totalResults = 0 ;
@@ -309,12 +318,22 @@ public function getOriginalRequest(): Request
309318
310319 /**
311320 * Get page
321+ *
322+ * @deprecated Use currentPage() instead
312323 */
313324 public function getPage (): int
314325 {
315326 return $ this ->page ;
316327 }
317328
329+ /**
330+ * Get the current page
331+ */
332+ public function getCurrentPage (): int
333+ {
334+ return $ this ->currentPage ;
335+ }
336+
318337 /**
319338 * Set the start page of the paginator
320339 *
0 commit comments