| Conditions | 8 |
| Paths | 5 |
| Total Lines | 34 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 23 | protected function processData(GridViewRequest $request) : array |
||
| 24 | { |
||
| 25 | if (empty($this->data)) { |
||
| 26 | return []; |
||
| 27 | } |
||
| 28 | |||
| 29 | $tmp = collect($this->data); |
||
| 30 | |||
| 31 | if (!empty($request->filters)) { |
||
| 32 | $tmp->filter(function($item) use ($request) { |
||
| 33 | foreach ($request->filters as $filterKey => $filterValue) { |
||
| 34 | |||
| 35 | if (!isset($item[$filterKey])) { |
||
| 36 | return false; |
||
| 37 | } |
||
| 38 | |||
| 39 | if (strpos($item[$filterKey], $filterValue) === false) { |
||
| 40 | return false; |
||
| 41 | } |
||
| 42 | } |
||
| 43 | |||
| 44 | return true; |
||
| 45 | }); |
||
| 46 | } |
||
| 47 | |||
| 48 | if (!empty($request->sortColumn)) { |
||
| 49 | $tmp = $tmp->sortBy( |
||
| 50 | $request->sortColumn, |
||
| 51 | $request->sortOrder == 'DESC' ? SORT_DESC : SORT_ASC |
||
| 52 | ); |
||
| 53 | } |
||
| 54 | |||
| 55 | return $tmp; |
||
| 56 | } |
||
| 57 | |||
| 76 | } |