Conditions | 3 |
Paths | 2 |
Total Lines | 16 |
Code Lines | 8 |
Lines | 0 |
Ratio | 0 % |
Tests | 9 |
CRAP Score | 3 |
Changes | 0 |
1 | <?php |
||
19 | 2 | public function enableSorts($sorts) |
|
20 | { |
||
21 | 2 | foreach (['desc', 'asc'] as $direction) { |
|
22 | 2 | $this->when( |
|
|
|||
23 | 2 | $this->request->input($direction), |
|
24 | function (Builder $query, $descAttribute) use ($sorts, $direction) { |
||
25 | 2 | if (array_key_exists($descAttribute, $sorts)) { |
|
26 | 1 | $descAttribute = Arr::get($sorts, $descAttribute); |
|
27 | } |
||
28 | |||
29 | 2 | return $query->orderBy($descAttribute, $direction); |
|
30 | 2 | } |
|
31 | ); |
||
32 | } |
||
33 | |||
34 | 2 | return $this; |
|
35 | } |
||
37 |