@@ -26,6 +26,22 @@ public static function string2utf8($string = '')
26
26
return $ string ;
27
27
}
28
28
29
+ public function customPaginate ($ items , $ total , $ pageSize = 15 )
30
+ {
31
+ $ paginate = new \Illuminate \Pagination \LengthAwarePaginator (
32
+ items: $ items ,
33
+ total: $ total ,
34
+ perPage: $ pageSize ,
35
+ currentPage: \request ('page ' ),
36
+ );
37
+
38
+ $ paginate
39
+ ->withPath ('/ ' .\request ()->path ())
40
+ ->withQueryString ();
41
+
42
+ return $ this ->paginate ($ paginate );
43
+ }
44
+
29
45
public function paginate (\Illuminate \Pagination \LengthAwarePaginator $ paginate , ?callable $ callable = null )
30
46
{
31
47
return $ this ->success ([
@@ -45,22 +61,6 @@ public function paginate(\Illuminate\Pagination\LengthAwarePaginator $paginate,
45
61
]);
46
62
}
47
63
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
-
64
64
public function success ($ data = [], $ err_msg = 'success ' , $ err_code = 200 , $ headers = [])
65
65
{
66
66
if (is_string ($ data )) {
@@ -81,6 +81,7 @@ public function success($data = [], $err_msg = 'success', $err_code = 200, $head
81
81
$ err_code = $ config_err_code ;
82
82
}
83
83
84
+ $ data = $ data ?: null ;
84
85
$ res = compact ('err_code ' , 'err_msg ' , 'data ' ) + array_filter (compact ('meta ' ));
85
86
86
87
return \response (
0 commit comments