File tree Expand file tree Collapse file tree 1 file changed +24
-7
lines changed
src/yajra/Datatables/Processors Expand file tree Collapse file tree 1 file changed +24
-7
lines changed Original file line number Diff line number Diff line change 22
33namespace yajra \Datatables \Processors ;
44
5- use Illuminate \Support \Arr ;
65use yajra \Datatables \Helper ;
76
87/**
@@ -73,12 +72,9 @@ public function process($object = false)
7372 $ value = $ this ->addColumns ($ data , $ row );
7473 $ value = $ this ->editColumns ($ value , $ row );
7574 $ value = $ this ->setupRowVariables ($ value , $ row );
76- if ( ! $ object ) {
77- $ value = Arr::flatten ($ this ->removeExcessColumns ($ value ));
78- } else {
79- $ value = $ this ->removeExcessColumns ($ value );
80- }
81- $ this ->output [] = $ value ;
75+ $ value = $ this ->removeExcessColumns ($ value );
76+
77+ $ this ->output [] = $ object ? $ value : $ this ->flatten ($ value );
8278 }
8379
8480 return $ this ->output ;
@@ -152,4 +148,25 @@ protected function removeExcessColumns(array $data)
152148 return $ data ;
153149 }
154150
151+ /**
152+ * Flatten array with exceptions.
153+ *
154+ * @param array $array
155+ * @return array
156+ */
157+ public function flatten (array $ array )
158+ {
159+ $ return = [];
160+ $ exceptions = ['DT_RowId ' , 'DT_RowClass ' , 'DT_RowData ' , 'DT_RowAttr ' ];
161+
162+ foreach ($ array as $ key => $ value ) {
163+ if (in_array ($ key , $ exceptions )) {
164+ $ return [$ key ] = $ value ;
165+ } else {
166+ $ return [] = $ value ;
167+ }
168+ }
169+
170+ return $ return ;
171+ }
155172}
You can’t perform that action at this time.
0 commit comments