@@ -6,74 +6,74 @@ |
||
6 | 6 | |
7 | 7 | class ArrayDataProvider extends BaseDataProvider |
8 | 8 | { |
9 | - /** |
|
10 | - * @var array |
|
11 | - */ |
|
12 | - private $data; |
|
9 | + /** |
|
10 | + * @var array |
|
11 | + */ |
|
12 | + private $data; |
|
13 | 13 | |
14 | - public function __construct(array $data) |
|
15 | - { |
|
16 | - $this->data = $data; |
|
17 | - } |
|
14 | + public function __construct(array $data) |
|
15 | + { |
|
16 | + $this->data = $data; |
|
17 | + } |
|
18 | 18 | |
19 | - /** |
|
20 | - * @param GridViewRequest $request |
|
21 | - * @return array |
|
22 | - */ |
|
23 | - protected function processData(GridViewRequest $request) : array |
|
24 | - { |
|
25 | - if (empty($this->data)) { |
|
26 | - return []; |
|
27 | - } |
|
19 | + /** |
|
20 | + * @param GridViewRequest $request |
|
21 | + * @return array |
|
22 | + */ |
|
23 | + protected function processData(GridViewRequest $request) : array |
|
24 | + { |
|
25 | + if (empty($this->data)) { |
|
26 | + return []; |
|
27 | + } |
|
28 | 28 | |
29 | - $tmp = collect($this->data); |
|
29 | + $tmp = collect($this->data); |
|
30 | 30 | |
31 | - if (!empty($request->filters)) { |
|
32 | - $tmp = $tmp->filter(function($item) use ($request) { |
|
33 | - foreach ($request->filters as $filterKey => $filterValue) { |
|
31 | + if (!empty($request->filters)) { |
|
32 | + $tmp = $tmp->filter(function($item) use ($request) { |
|
33 | + foreach ($request->filters as $filterKey => $filterValue) { |
|
34 | 34 | |
35 | - if (!isset($item[$filterKey])) { |
|
36 | - return false; |
|
37 | - } |
|
35 | + if (!isset($item[$filterKey])) { |
|
36 | + return false; |
|
37 | + } |
|
38 | 38 | |
39 | - if (strpos($item[$filterKey], $filterValue) === false) { |
|
40 | - return false; |
|
41 | - } |
|
42 | - } |
|
39 | + if (strpos($item[$filterKey], $filterValue) === false) { |
|
40 | + return false; |
|
41 | + } |
|
42 | + } |
|
43 | 43 | |
44 | - return true; |
|
45 | - }); |
|
46 | - } |
|
44 | + return true; |
|
45 | + }); |
|
46 | + } |
|
47 | 47 | |
48 | - if (!empty($request->sortColumn)) { |
|
49 | - $tmp = $tmp->sortBy( |
|
50 | - $request->sortColumn, |
|
51 | - SORT_REGULAR, |
|
52 | - $request->sortOrder == 'DESC' |
|
53 | - ); |
|
54 | - } |
|
48 | + if (!empty($request->sortColumn)) { |
|
49 | + $tmp = $tmp->sortBy( |
|
50 | + $request->sortColumn, |
|
51 | + SORT_REGULAR, |
|
52 | + $request->sortOrder == 'DESC' |
|
53 | + ); |
|
54 | + } |
|
55 | 55 | |
56 | - return $tmp->values()->all(); |
|
57 | - } |
|
56 | + return $tmp->values()->all(); |
|
57 | + } |
|
58 | 58 | |
59 | - /** |
|
60 | - * @inheritdoc |
|
61 | - */ |
|
62 | - public function getCount(GridViewRequest $request) : int |
|
63 | - { |
|
64 | - return count($this->processData($request)); |
|
65 | - } |
|
59 | + /** |
|
60 | + * @inheritdoc |
|
61 | + */ |
|
62 | + public function getCount(GridViewRequest $request) : int |
|
63 | + { |
|
64 | + return count($this->processData($request)); |
|
65 | + } |
|
66 | 66 | |
67 | - /** |
|
68 | - * @inheritdoc |
|
69 | - */ |
|
70 | - public function getData(GridViewRequest $request) |
|
71 | - { |
|
72 | - $tmp = $this->processData($request); |
|
67 | + /** |
|
68 | + * @inheritdoc |
|
69 | + */ |
|
70 | + public function getData(GridViewRequest $request) |
|
71 | + { |
|
72 | + $tmp = $this->processData($request); |
|
73 | 73 | |
74 | - return array_splice( |
|
75 | - $tmp, |
|
76 | - ($request->page -1) * $request->perPage, $request->perPage |
|
77 | - ); |
|
78 | - } |
|
74 | + return array_splice( |
|
75 | + $tmp, |
|
76 | + ($request->page -1) * $request->perPage, $request->perPage |
|
77 | + ); |
|
78 | + } |
|
79 | 79 | } |
80 | 80 | \ No newline at end of file |
@@ -73,7 +73,7 @@ |
||
73 | 73 | |
74 | 74 | return array_splice( |
75 | 75 | $tmp, |
76 | - ($request->page -1) * $request->perPage, $request->perPage |
|
76 | + ($request->page - 1) * $request->perPage, $request->perPage |
|
77 | 77 | ); |
78 | 78 | } |
79 | 79 | } |
80 | 80 | \ No newline at end of file |