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