private function buildSubclauseQuery($query, $rule, $value, $condition)
    {
        /*
         * Convert the Operator (LIKE/NOT LIKE/GREATER THAN) given to us by QueryBuilder
         * into on one that we can use inside the SQL query
         */
        $_sql_op = $this->operator_sql[$rule->operator];
        $operator = $_sql_op['operator'];
        $require_array = $this->operatorRequiresArray($operator);

        $subclause = $this->joinFields[$rule->field];
        $subclause['operator'] = $operator;
        $subclause['value'] = $value;
        $subclause['require_array'] = $require_array;

        $not = array_key_exists('not_exists', $subclause) && $subclause['not_exists'];

        // Create a where exists clause to join to the other table, and find results matching the criteria
        $query = $query->whereExists(
            /**
             * @param Builder $query
             */
            function(Builder $query) use ($subclause) {

                $q = $query->selectRaw(1)
                    ->from($subclause['to_table'])
                    ->whereRaw($subclause['to_table'].'.'.$subclause['to_col']
                        .' = '
                        .$subclause['from_table'].'.'.$subclause['from_col']);

                if (array_key_exists('to_clause', $subclause)) {
                    $q->where($subclause['to_clause']);
                }

                $this->buildSubclauseInnerQuery($subclause, $q);
            },
            $condition,
            $not
        );

        return $query;
    }
private function buildSubclauseQuery($query, $rule, $value, $condition)
    {
        /*
         * Convert the Operator (LIKE/NOT LIKE/GREATER THAN) given to us by QueryBuilder
         * into on one that we can use inside the SQL query
         */
        $_sql_op = $this->operator_sql[$rule->operator];
        $operator = $_sql_op['operator'];
        $require_array = $this->operatorRequiresArray($operator);

        $subclause = $this->joinFields[$rule->field];
        $subclause['operator'] = $operator;
        $subclause['value'] = $value;
        $subclause['require_array'] = $require_array;

        $not = array_key_exists('not_exists', $subclause) && $subclause['not_exists'];

        // Create a where exists clause to join to the other table, and find results matching the criteria
        $query = $query->whereExists(
            /**
             * @param Builder $query
             */
            function(Builder $query) use ($subclause) {

                $q = $query->selectRaw(1)
                    ->from($subclause['to_table'])
                    ->whereRaw($subclause['to_table'].'.'.$subclause['to_col']
                        .' = '
                        .$subclause['from_table'].'.'.$subclause['from_col']);

                if (array_key_exists('to_clause', $subclause)) {
                    $q->where($subclause['to_clause']);
                }

                $this->buildSubclauseInnerQuery($subclause, $q);
            },
            $condition,
            $not
        );

        return $query;
    }
private function buildSubclauseQuery ( $ query , $ rule , $ value , $ condition ) { /*
         * Convert the Operator (LIKE/NOT LIKE/GREATER THAN) given to us by QueryBuilder
         * into on one that we can use inside the SQL query
         */ $ _sql_op = $ this -> operator_sql [ $ rule -> operator ] ; $ operator = $ _sql_op [ 'operator' ] ; $ require_array = $ this -> operatorRequiresArray ( $ operator ) ; $ subclause = $ this -> joinFields [ $ rule -> field ] ; $ subclause [ 'operator' ] = $ operator ; $ subclause [ 'value' ] = $ value ; $ subclause [ 'require_array' ] = $ require_array ; $ not = array_key_exists ( 'not_exists' , $ subclause ) && $ subclause [ 'not_exists' ] ; // Create a where exists clause to join to the other table, and find results matching the criteria $ query = $ query -> whereExists ( /**
             * @param Builder $query
             */ function ( Builder $ query ) use ( $ subclause ) { $ q = $ query -> selectRaw ( 1 ) -> from ( $ subclause [ 'to_table' ] ) -> whereRaw ( $ subclause [ 'to_table' ] . '.' . $ subclause [ 'to_col' ] . ' = ' . $ subclause [ 'from_table' ] . '.' . $ subclause [ 'from_col' ] ) ; if ( array_key_exists ( 'to_clause' , $ subclause ) ) { $ q -> where ( $ subclause [ 'to_clause' ] ) ; } $ this -> buildSubclauseInnerQuery ( $ subclause , $ q ) ; } , $ condition , $ not ) ; return $ query ; }
Build a subquery clause if there are join fields that have been specified.

@param Builder $query
@param stdClass $rule
@param string|null $value
@return Builder the query builder object
Build a subquery clause if there are join fields that have been specified .