Conditions | 1 |
Paths | 1 |
Total Lines | 11 |
Code Lines | 6 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
28 | public function getAllAuthor(Request $request): LengthAwarePaginator |
||
29 | { |
||
30 | $data = User::query() |
||
31 | ->withCount('posts'); //Eloquent method |
||
32 | |||
33 | $orderBy = (string) Arr::get($request->toArray(), 'order_by', 'posts_count'); |
||
34 | $order = (string) Arr::get($request->toArray(), 'order', 'desc'); |
||
35 | |||
36 | $data = $data->orderBy($orderBy, $order); |
||
37 | |||
38 | return $data->paginate($request->integer('per_page', 10)); |
||
39 | } |
||
41 |