Skip to content

Commit c361300

Browse files
authored
Update ResponseTrait.php
1 parent 4743346 commit c361300

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/Traits/ResponseTrait.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,18 @@ public static function string2utf8($string = '')
2626
return $string;
2727
}
2828

29+
public function paginate(\Illuminate\Pagination\LengthAwarePaginator $paginate)
30+
{
31+
return $this->success([
32+
'meta' => [
33+
'total' => $paginate->total(),
34+
'current_page' => $paginate->currentPage(),
35+
'per_page' => $paginate->perPage(),
36+
],
37+
'data' => $paginate->items(),
38+
]);
39+
}
40+
2941
public function success($data = [], $err_msg = 'success', $err_code = 200, $headers = [])
3042
{
3143
if (is_string($data)) {

0 commit comments

Comments
 (0)