Skip to content

Commit 66bbb3c

Browse files
Fix Query pagination. (#52)
1 parent 0448830 commit 66bbb3c

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/Query/Query.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ public function paginate($per_page = 5, $page = null, $page_name = 'imap_page'){
289289

290290
$this->limit = $per_page;
291291

292-
return $this->get()->paginate($per_page, $this->page, $page_name);
292+
return $this->get()->paginate($per_page, $this->page, $page_name, true);
293293
}
294294

295295
/**

src/Support/PaginatedCollection.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,12 @@ class PaginatedCollection extends Collection {
3838
*
3939
* @return LengthAwarePaginator
4040
*/
41-
public function paginate($per_page = 15, $page = null, $page_name = 'page') {
41+
public function paginate($per_page = 15, $page = null, $page_name = 'page', $prepaginated = false) {
4242
$page = $page ?: Paginator::resolveCurrentPage($page_name);
4343

4444
$total = $this->total ? $this->total : $this->count();
4545

46-
$results = $total ? $this->forPage($page, $per_page) : $this->all();
46+
$results = !$prepaginated && $total ? $this->forPage($page, $per_page) : $this->all();
4747

4848
return $this->paginator($results, $total, $per_page, $page, [
4949
'path' => Paginator::resolveCurrentPath(),
@@ -78,4 +78,4 @@ public function total($total = null) {
7878

7979
return $this->total = $total;
8080
}
81-
}
81+
}

0 commit comments

Comments
 (0)