Adds the join table to the query

@param Select $query
@return self
198312
protected function addJoinTable(Select $query)
    {
        $relationTable = $this->getRelationTable();
        $table = $this->getParentTableName();
        $pmk = $this->getParentPrimaryKey();
        $rfk = $this->getRelatedForeignKey();
        $query->join(
            $relationTable,
            "rel.{$rfk} = {$table}.{$pmk}",
            null,
            'rel'
        );
        return $this;
    }
626196
private function formJoin($query, $parentTable, $relatedTable, $parentPrimaryKey, $relatedPrimaryKey)
    {
        $joinType = config('columnsortable.join_type', 'leftJoin');

        return $query->select($parentTable.'.*')->{$joinType}($relatedTable, $parentPrimaryKey, '=', $relatedPrimaryKey);
    }
514626
public function setQuery(Query $query)
    {
        $this->query = $query;
        $this->clonedQuery = clone $query;

        return $this;
    }
1200032
public function addNestedWhereQuery($query)
    {
        if (count($query->wheres)) {
            $wheres = $this->wheres ?: [];

            $this->wheres = array_merge($wheres, $query->wheres);
        }

        return $this;
    }
756368
protected function _setJoins()
    {
        $joins = $this->_sql->getJoins();
        foreach ($joins as $join) {
            $this->_statement .= $this->_createJoinStatement($join);
        }
        return $this;
    }
230925
public function mergeToQuery(Select $query)
    {
        $query->join(
            $this->getKeyCondition(),
            $this->getQuery()->getWhere()->build(),
            null,
            $this->getQuery()->getBinds('where')
        );

        foreach ($this->select as $select) {
            $query->prependSelect($select);
        }

        foreach ($this->getQuery()->getSelect() as $key => $select) {
            $query->prependSelect([$key => $select]);
        }

        foreach ($this->getQuery()->getJoin() as $join) {
            $query->join($join, null, null, $this->getQuery()->getBinds('join', true));
        }

        if ($groupBy = $this->getQuery()->getGroupBy()) {
            $query->groupBy($groupBy);
        }

        if (($having = $this->getQuery()->getHaving()) && $having->hasChildren()) {
            $query->having($having);
        }

        if ($orderBy = $this->getQuery()->getOrderBy()) {
            $query->orderBy($orderBy);
        }

        return $this;
    }
213978
public function withQuery(array $query = [])
    {
        // Set Query in class.
        $this->query = collect($this->query)->merge($query)->all();

        return $this;
    }
372068
public function mergeWithCollection(EntityRepository $collection, $join_on_key, $join_index = 'id', $join_type = 'INNER'): self
    {
        $this->addJoinTable($collection->getDbTableName(), $join_index, $join_on_key, $join_type);
        $this->mergeCollectionSqlSelectWithAnotherCollection($collection);

        return $this;
    }
996903
protected function setJoin(Builder $query = null)
    {
        $query = $query ?: $this->query;

        $foreignKey = $this->related->getTable().'.'.$this->related->getKeyName();

        $localKey = $this->parent->getTable().'.'.$this->secondKey;

        $query->join($this->parent->getTable(), $localKey, '=', $foreignKey);
    }
855856
public function addJoinObject(Join $join)
    {
        $isAlreadyAdded = false;
        foreach ($this->joins as $alreadyAddedJoin) {
            if ($join->equals($alreadyAddedJoin)) {
                $isAlreadyAdded = true;
                break;
            }
        }

        if (!$isAlreadyAdded) {
            $this->joins[] = $join;
        }

        return $this;
    }
748989
public function joinRaw(string $sql)
    {
        $this->sqlParts['join'][] = $this->getAdapter()->quoteSql($sql);

        return $this;
    }
378971
protected function joinMapped(Builder $query, $target)
    {
        $query->prefixColumnsForJoin();

        $parent = $this;

        foreach (explode('.', $target) as $segment) {
            list($table, $parent) = $this->joinSegment($query, $segment, $parent);
        }

        return $table;
    }
537767
protected function alreadyJoined(Builder $query, $table)
    {
        $joined = Arr::pluck((array) $query->getQuery()->joins, 'table');

        return in_array($table, $joined);
    }
1332251
public function mergeBindings(Builder $query)
    {
        $this->bindings = array_merge_recursive($this->bindings, $query->bindings);

        return $this;
    }
1132457
public function addSelect($select)
    {
        if (null === $select) {
            return $this;
        }
        if (is_array($select)) {
            $t = [];
            foreach ($select as $field => $alias) {
                if (is_int($field)) {
                    $alias = $this->quoteColumnName($alias);
                    array_push($t, "{$alias}");
                } else {
                    $field = $this->quoteColumnName($field);
                    $alias = $this->quoteColumnName($alias);
                    array_push($t, "{$field} AS {$alias}");
                }
            }
            $select = implode(',', $t);
        }
        if (isset($this->query['select']) && !empty($this->query['select'])) {
            $select = "{$this->query['select']},{$select}";
        }
        $this->query['select'] = $select;
        return $this;
    }
271226
public function setQuery($query)
    {
        if (!empty($query)) {
            $this->data['query'] = $this->_queryToArray($query);
        }

        return $this;
    }
1110223
public function union(\pwf\components\querybuilder\interfaces\QueryBuilder $query)
    {
        $this->union[] = $query;
        return $this;
    }