classes/Input/Search.php
private function condition($query, $field, $comparison, $input, $type)
    {
        // Convert date formats
        if ($type == 'date') {
            $field = $this->convertDateField($field);
            $input = Carbon::createFromFormat(__('decoy::form.date.format'), $input)
                ->format('Y-m-d');
        }

        // Apply the where
        switch ($comparison) {

            // NULL safe equals and not equals
			case '=':
			case '!=':
				return $this->applyEquality($comparison, $query, $field, $input);

            // Not Like
            case '!%*%':
                $comparison = substr($comparison, 1);
                $input = str_replace('*', $input, $comparison);
                return $query->where($field, 'NOT LIKE', $input);

            // Like
            case '*%':
            case '%*':
            case '%*%':
                $input = str_replace('*', $input, $comparison);
                return $query->where($field, 'LIKE', $input);

            // Defaults
            default:
                return $query->where($field, $comparison, $input);
        }
    }
private function condition($query, $field, $comparison, $input, $type)
    {
        // Convert date formats
        if ($type == 'date') {
            $field = $this->convertDateField($field);
            $input = Carbon::createFromFormat(__('decoy::form.date.format'), $input)
                ->format('Y-m-d');
        }

        // Apply the where
        switch ($comparison) {

            // NULL safe equals and not equals
			case '=':
			case '!=':
				return $this->applyEquality($comparison, $query, $field, $input);

            // Not Like
            case '!%*%':
                $comparison = substr($comparison, 1);
                $input = str_replace('*', $input, $comparison);
                return $query->where($field, 'NOT LIKE', $input);

            // Like
            case '*%':
            case '%*':
            case '%*%':
                $input = str_replace('*', $input, $comparison);
                return $query->where($field, 'LIKE', $input);

            // Defaults
            default:
                return $query->where($field, $comparison, $input);
        }
    }
private function condition ( $ query , $ field , $ comparison , $ input , $ type ) { // Convert date formats if ( $ type == 'date' ) { $ field = $ this -> convertDateField ( $ field ) ; $ input = Carbon :: createFromFormat ( __ ( 'decoy::form.date.format' ) , $ input ) -> format ( 'Y-m-d' ) ; } // Apply the where switch ( $ comparison ) { // NULL safe equals and not equals case '=' : case '!=' : return $ this -> applyEquality ( $ comparison , $ query , $ field , $ input ) ; // Not Like case '!%*%' : $ comparison = substr ( $ comparison , 1 ) ; $ input = str_replace ( '*' , $ input , $ comparison ) ; return $ query -> where ( $ field , 'NOT LIKE' , $ input ) ; // Like case '*%' : case '%*' : case '%*%' : $ input = str_replace ( '*' , $ input , $ comparison ) ; return $ query -> where ( $ field , 'LIKE' , $ input ) ; // Defaults default : return $ query -> where ( $ field , $ comparison , $ input ) ; } }
Add a condition to a query

@param  Illuminate\Database\Query\Builder $query
@param  string                            $field      The field name from search config
@param  string                            $comparison The operator string from the search UI
@param  string                            $input      The input for the field
@param  string                            $type       The type of the field
@return Illuminate\Database\Query\Builder
Add a condition to a query