public static function getQueryWhere($request, $query, $parameters)
    {
        $indexColumns   = isset($parameters['indexColumns'])? $parameters['indexColumns'] : null;
        $where          = isset($parameters['where'])? $parameters['where'] : null;
        $whereColumns   = isset($parameters['whereColumns'])? $parameters['whereColumns'] : null;
        
        if($where != null)
        {
            $columns = $request->input('columns');

            $query->where(function($query) use ($columns, $indexColumns, $where){
                $i=0;
                foreach($indexColumns as $indexColumn)
                {
                    // check if column if is searchable
                    if($columns[$i]['searchable'] === 'true')
                    {
                        if(is_array($indexColumn)) $indexColumn = $indexColumn['data'];
                        
                        $query->orWhere($indexColumn, 'LIKE', '%' . $where . '%');
                    }
                    $i++;
                }
            });
        }

        if(is_array($whereColumns))
        {
            $query->where(function($query) use ($whereColumns) {
                foreach($whereColumns as $whereColumn)
                {
                    // enable option to be null value, with NULL
                    if($whereColumn['value'] == 'NULL')
                        $whereColumn['value'] = null;

                    $query->where($whereColumn['column'], $whereColumn['operator'], $whereColumn['value']);
                }
            });
        }

        return $query;
    }
public static function getQueryWhere($request, $query, $parameters)
    {
        $indexColumns   = isset($parameters['indexColumns'])? $parameters['indexColumns'] : null;
        $where          = isset($parameters['where'])? $parameters['where'] : null;
        $whereColumns   = isset($parameters['whereColumns'])? $parameters['whereColumns'] : null;
        
        if($where != null)
        {
            $columns = $request->input('columns');

            $query->where(function($query) use ($columns, $indexColumns, $where){
                $i=0;
                foreach($indexColumns as $indexColumn)
                {
                    // check if column if is searchable
                    if($columns[$i]['searchable'] === 'true')
                    {
                        if(is_array($indexColumn)) $indexColumn = $indexColumn['data'];
                        
                        $query->orWhere($indexColumn, 'LIKE', '%' . $where . '%');
                    }
                    $i++;
                }
            });
        }

        if(is_array($whereColumns))
        {
            $query->where(function($query) use ($whereColumns) {
                foreach($whereColumns as $whereColumn)
                {
                    // enable option to be null value, with NULL
                    if($whereColumn['value'] == 'NULL')
                        $whereColumn['value'] = null;

                    $query->where($whereColumn['column'], $whereColumn['operator'], $whereColumn['value']);
                }
            });
        }

        return $query;
    }
public static function getQueryWhere ( $ request , $ query , $ parameters ) { $ indexColumns = isset ( $ parameters [ 'indexColumns' ] ) ? $ parameters [ 'indexColumns' ] : null ; $ where = isset ( $ parameters [ 'where' ] ) ? $ parameters [ 'where' ] : null ; $ whereColumns = isset ( $ parameters [ 'whereColumns' ] ) ? $ parameters [ 'whereColumns' ] : null ; if ( $ where != null ) { $ columns = $ request -> input ( 'columns' ) ; $ query -> where ( function ( $ query ) use ( $ columns , $ indexColumns , $ where ) { $ i = 0 ; foreach ( $ indexColumns as $ indexColumn ) { // check if column if is searchable if ( $ columns [ $ i ] [ 'searchable' ] === 'true' ) { if ( is_array ( $ indexColumn ) ) $ indexColumn = $ indexColumn [ 'data' ] ; $ query -> orWhere ( $ indexColumn , 'LIKE' , '%' . $ where . '%' ) ; } $ i ++ ; } } ) ; } if ( is_array ( $ whereColumns ) ) { $ query -> where ( function ( $ query ) use ( $ whereColumns ) { foreach ( $ whereColumns as $ whereColumn ) { // enable option to be null value, with NULL if ( $ whereColumn [ 'value' ] == 'NULL' ) $ whereColumn [ 'value' ] = null ; $ query -> where ( $ whereColumn [ 'column' ] , $ whereColumn [ 'operator' ] , $ whereColumn [ 'value' ] ) ; } } ) ; } return $ query ; }
Function to set arguments to SQL query

@access  public
@param   \Illuminate\Http\Request $request
@param   array   $query
@param   array   $parameters
@return  Illuminate/Database/Eloquent/Builder
Function to set arguments to SQL query