@@ -79,6 +79,7 @@ public function getArray()
7979 public function reset ()
8080 {
8181 $ this ->workingCollection = $ this ->collection ;
82+ return $ this ;
8283 }
8384
8485 public function stripSearch ()
@@ -143,20 +144,27 @@ private function doInternalSearch(Collection $columns, array $searchColumns)
143144 $ ii ++;
144145 }
145146
146- $ this ->workingCollection = $ this ->workingCollection ->filter (function ($ row ) use ($ value , $ toSearch , $ caseSensitive )
147+ $ self = $ this ;
148+ $ this ->workingCollection = $ this ->workingCollection ->filter (function ($ row ) use ($ value , $ toSearch , $ caseSensitive , $ self )
147149 {
148150 for ($ i = 0 ; $ i < count ($ row ); $ i ++)
149151 {
150152 if (!in_array ($ i , $ toSearch ))
151153 continue ;
152154
155+ $ column = $ i ;
156+ if ($ self ->aliasMapping )
157+ {
158+ $ column = $ self ->getNameByIndex ($ i );
159+ }
160+
153161 if ($ this ->options ['stripSearch ' ])
154162 {
155- $ search = strip_tags ($ row [$ i ]);
163+ $ search = strip_tags ($ row [$ column ]);
156164 }
157165 else
158166 {
159- $ search = $ row [$ i ];
167+ $ search = $ row [$ column ];
160168 }
161169 if ($ caseSensitive )
162170 {
@@ -179,8 +187,13 @@ private function doInternalOrder()
179187
180188 $ column = $ this ->orderColumn ;
181189 $ stripOrder = $ this ->options ['stripOrder ' ];
182- $ this ->workingCollection ->sortBy (function ($ row ) use ($ column ,$ stripOrder ) {
190+ $ self = $ this ;
191+ $ this ->workingCollection ->sortBy (function ($ row ) use ($ column ,$ stripOrder ,$ self ) {
183192
193+ if ($ self ->aliasMapping )
194+ {
195+ $ column = $ self ->getNameByIndex ($ column );
196+ }
184197 if ($ stripOrder )
185198 {
186199 return strip_tags ($ row [$ column ]);
@@ -212,7 +225,15 @@ private function compileArray($columns)
212225 $ i =0 ;
213226 foreach ($ columns as $ col )
214227 {
215- $ entry [$ i ] = $ col ->run ($ row );
228+ if ($ this ->aliasMapping )
229+ {
230+ $ entry [$ col ->getName ()] = $ col ->run ($ row );
231+ }
232+ else
233+ {
234+ $ entry [$ i ] = $ col ->run ($ row );
235+ }
236+
216237 $ i ++;
217238 }
218239 return $ entry ;
0 commit comments