We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent b60025d commit 97589a7Copy full SHA for 97589a7
src/Traits/WebmanResponseTrait.php
@@ -26,15 +26,21 @@ public static function string2utf8($string = '')
26
return $string;
27
}
28
29
- public function paginate(\Illuminate\Pagination\LengthAwarePaginator $paginate)
+ public function paginate(\Illuminate\Pagination\LengthAwarePaginator $paginate, ?callable $callable = null)
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(),
+ 'data' => array_map(function ($item) use ($callable) {
38
+ if ($callable) {
39
+ return $callable($item) ?? $item;
40
+ }
41
+
42
+ return $item;
43
+ }, $paginate->items()),
44
]);
45
46
0 commit comments