Skip to content

Commit e95cb5d

Browse files
authored
Update ResponseTrait.php
1 parent 8588eb9 commit e95cb5d

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/Traits/ResponseTrait.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,22 @@ public function paginate(\Illuminate\Pagination\LengthAwarePaginator $paginate,
4545
]);
4646
}
4747

48+
public function customPaginate($items, $total, $pageSize = 15)
49+
{
50+
$paginate = new \Illuminate\Pagination\LengthAwarePaginator(
51+
items: $items,
52+
total: $total,
53+
perPage: $pageSize,
54+
currentPage: \request('page'),
55+
);
56+
57+
$paginate
58+
->withPath('/'.\request()->path())
59+
->withQueryString();
60+
61+
return $this->paginate($paginate);
62+
}
63+
4864
public function success($data = [], $err_msg = 'success', $err_code = 200, $headers = [])
4965
{
5066
if (is_string($data)) {

0 commit comments

Comments
 (0)