Conditions | 3 |
Paths | 2 |
Total Lines | 13 |
Code Lines | 7 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
1 | <?php |
||
16 | public function __construct(Request $request) |
||
17 | { |
||
18 | $params = $request->filled('sort') ? explode(',', $request->get('sort')) : []; |
||
19 | |||
20 | $this->fields = collect($params)->map(function ($field) { |
||
|
|||
21 | $direction = SortField::SORT_ASCENDING; |
||
22 | |||
23 | if (Str::startsWith($field, '-')) { |
||
24 | $direction = SortField::SORT_DESCENDING; |
||
25 | $field = Str::after($field, '-'); |
||
26 | } |
||
27 | |||
28 | return new SortField($field, $direction); |
||
29 | }); |
||
37 |