55class ArrayAdapter extends AdapterInterface {
66
77 protected $ array = [];
8- protected $ filter = [];
8+ protected $ column = [];
9+ protected $ global = [];
910 protected $ order = [];
1011
1112 public function setArray (array $ array ) {
@@ -18,25 +19,38 @@ public function getResponse() {
1819 $ total = count ($ this ->array );
1920
2021 $ this ->bind ('global_search ' , function ($ column , $ search ) {
21- $ this ->filter [$ column ][] = $ search ;
22+ $ this ->global [$ column ][] = $ search ;
2223 });
2324
2425 $ this ->bind ('column_search ' , function ($ column , $ search ) {
25- $ this ->filter [$ column ][] = $ search ;
26+ $ this ->column [$ column ][] = $ search ;
2627 });
2728
2829 $ this ->bind ('order ' , function ($ order ) {
2930 $ this ->order = $ order ;
3031 });
3132
32- if (count ($ this ->filter )) {
33+ if (count ($ this ->global ) || count ( $ this -> column )) {
3334 $ items = array_filter ($ this ->array , function ($ item ) {
34- $ check = true ;
35+ $ check = false ;
36+
37+ if (count ($ this ->global )) {
38+ foreach ($ this ->global as $ column =>$ filters ) {
39+ foreach ($ filters as $ search ) {
40+ $ check = (strpos ($ item [$ column ], $ search ) !== false );
41+ if ($ check ) break 2 ;
42+ }
43+ }
44+ } else {
45+ $ check = true ;
46+ }
3547
36- foreach ($ this ->filter as $ column =>$ filters ) {
37- foreach ($ filters as $ search ) {
38- $ check = (strpos ($ item [$ column ], $ search ) !== false );
39- if (!$ check ) break 2 ;
48+ if (count ($ this ->column ) && $ check ) {
49+ foreach ($ this ->column as $ column =>$ filters ) {
50+ foreach ($ filters as $ search ) {
51+ $ check = (strpos ($ item [$ column ], $ search ) !== false );
52+ if (!$ check ) break 2 ;
53+ }
4054 }
4155 }
4256
0 commit comments