7
7
*
8
8
* @package Laravel
9
9
* @category Bundle
10
- * @version 1.3.1
10
+ * @version 1.3.3
11
11
* @author Bilal Gultekin <bilal@bilal.im>
12
12
*/
13
13
@@ -345,7 +345,7 @@ private function ordering()
345
345
346
346
if (!is_null (Input::get ('iSortCol_0 ' )))
347
347
{
348
- $ columns = $ this ->cleanColumns ( $ this ->last_columns );
348
+ $ columns = $ this ->clean_columns ( $ this ->last_columns );
349
349
350
350
for ( $ i =0 , $ c =intval (Input::get ('iSortingCols ' )); $ i <$ c ; $ i ++ )
351
351
{
@@ -360,15 +360,16 @@ private function ordering()
360
360
}
361
361
/**
362
362
* @param array $cols
363
+ * @param bool $use_alias weather to get the column/function or the alias
363
364
* @return array
364
365
*/
365
- private function cleanColumns ( $ cols )
366
+ private function clean_columns ( $ cols, $ use_alias = true )
366
367
{
367
368
$ return = array ();
368
369
foreach ( $ cols as $ i => $ col )
369
370
{
370
371
preg_match ('#^(.*?)\s+as\s+(\S*?)$#si ' ,$ col ,$ matches );
371
- $ return [$ i ] = empty ($ matches ) ? $ col : $ matches [2 ];
372
+ $ return [$ i ] = empty ($ matches ) ? $ col : $ matches [$ use_alias ? 2 : 1 ];
372
373
}
373
374
374
375
return $ return ;
@@ -382,7 +383,7 @@ private function cleanColumns( $cols )
382
383
383
384
private function filtering ()
384
385
{
385
- $ columns = $ this ->cleanColumns ( $ this ->columns );
386
+ $ columns = $ this ->clean_columns ( $ this ->columns , false );
386
387
387
388
if (Input::get ('sSearch ' ,'' ) != '' )
388
389
{
@@ -448,7 +449,8 @@ private function filtering()
448
449
$ column = $ db_prefix . $ columns [$ i ];
449
450
$ this ->query ->where (DB ::raw ('LOWER( ' .$ column .') ' ),'LIKE ' , $ keyword );
450
451
} else {
451
- $ this ->query ->where ($ columns [$ i ], 'LIKE ' , $ keyword );
452
+ $ col = strstr ($ columns [$ i ],'( ' )?DB ::raw ($ columns [$ i ]):$ columns [$ i ];
453
+ $ this ->query ->where ($ col ], 'LIKE ' , $ keyword );
452
454
}
453
455
}
454
456
}
0 commit comments