Skip to content

Commit 460de44

Browse files
authored
Update WebmanResponseTrait.php
1 parent e95cb5d commit 460de44

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

src/Traits/WebmanResponseTrait.php

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public static function string2utf8($string = '')
2525

2626
return $string;
2727
}
28-
28+
2929
public function paginate(\Illuminate\Pagination\LengthAwarePaginator $paginate, ?callable $callable = null)
3030
{
3131
return $this->success([
@@ -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)