protected function joinManyToManyRelation(Relations\BelongsToMany $relation, $type)
 {
     $pivotTable = $relation->getTable();
     // $relation->getQualifiedParentKeyName() is protected
     $parentKey = $relation->getParent()->getQualifiedKeyName();
     $localKey = $relation->getOtherKey();
     $this->query->join($pivotTable, $localKey, '=', $parentKey, $type);
     $related = $relation->getRelated();
     $foreignKey = $relation->getForeignKey();
     $relatedTable = $related->getTable();
     $relatedKey = $related->getQualifiedKeyName();
     $this->query->join($relatedTable, $foreignKey, '=', $relatedKey, $type);
 }
Example #2
0
 /**
  * Init nested query for filter.
  *
  * @param QueryBuilder $query
  * @param array $ids
  *
  * @return void
  */
 protected function initNestedQuery(QueryBuilder $query, array $ids)
 {
     $connection = $query->getConnection();
     $keyName = $connection->raw($this->relation->getParent()->getQualifiedKeyName());
     $query->from($this->relation->getTable())->select($connection->raw('1'))->where($this->relation->getForeignKey(), '=', $keyName)->whereIn($this->relation->getOtherKey(), $ids);
 }