@param array $relations

@return $this
160978
public function relations(array $relations)
    {
        foreach ($relations as $column1 => $column2) {
            $this->relation($column1, $column2);
        }

        return $this;
    }
97818
public function removeRel($relation)
        {
            if (isset($this->_rel[$relation])) {
                unset($this->_rel[$relation]);
            }

            return $this;
        }
684938
public function loadMissing($relations)
    {
        $relations = is_string($relations) ? func_get_args() : $relations;

        $this->newCollection([$this])->loadMissing($relations);

        return $this;
    }
1326946
protected function associateRelationModels(string $relationName, EloquentCollection $relationModels): self
    {
        $relation = $this->getRelationInstance($relationName);

        $relation->match(
            $this->models->all(),
            $relationModels,
            $relationName
        );

        return $this;
    }
1179583
public function setAttachments(array $attachments): self
    {
        $this->clearAttachments();

        foreach ($attachments as $attachment) {
            $this->attach($attachment);
        }

        return $this;
    }
139332
public function leftJoinRelations($relations)
    {
        $relations = is_array($relations) ? $relations : func_get_args();

        return $this->joinRelations($relations, 'left');
    }
102106
public function related($relation, $conditions = array())
	{
		if (is_array($relation))
		{
			foreach ($relation as $k_r => $v_r)
			{
				is_array($v_r) ? $this->related($k_r, $v_r) : $this->related($v_r);
			}
			return $this;
		}

		if (strpos($relation, '.'))
		{
			$rels = explode('.', $relation);
			$model = $this->model;
			foreach ($rels as $r)
			{
				$rel = call_user_func(array($model, 'relations'), $r);
				if (empty($rel))
				{
					throw new \UnexpectedValueException('Relation "'.$r.'" was not found in the model "'.$model.'".');
				}
				$model = $rel->model_to;
			}
		}
		else
		{
			$rel = call_user_func(array($this->model, 'relations'), $relation);
			if (empty($rel))
			{
				throw new \UnexpectedValueException('Relation "'.$relation.'" was not found in the model.');
			}
		}

		$this->relations[$relation] = array($rel, $conditions);

		if ( ! empty($conditions['related']))
		{
			$conditions['related'] = (array) $conditions['related'];
			foreach ($conditions['related'] as $k_r => $v_r)
			{
				is_array($v_r) ? $this->related($relation.'.'.$k_r, $v_r) : $this->related($relation.'.'.$v_r);
			}

			unset($conditions['related']);
		}

		return $this;
	}
86577
public function with($relation)
    {
        $this->reset();

        if (func_num_args() > 1) {
            return $this->with(func_get_args());
        }

        if (is_array($relation)) {
            $this->related = array_merge($this->related, $relation);
        } else {
            $this->related[] = $relation;
        }

        $this->relatedCount = count($this->related);

        return $this;
    }
862134
protected function maxDepthFromRelations(array $relations)
    {

        if (!$relations) {
            return 1;
        }

        $max = 1;

        foreach ($relations as $path) {
            $max = max($max, count(explode('.', $path)));
        }

        // max has to be relation depth +1 because we want to have the
        // keys of that relation too
        return (int)$max + 1;

    }
1111105
public function whereHas($relation)
    {
        if ( ! is_array($relation)) {
            $relation = func_get_args();
        }

        $this->whereHas[] = $relation;

        return $this;
    }
160794
public function initRelation(array $models, $relation)
    {
        foreach ($models as $model) {
            $model->setRelation($relation, $this->getDefaultFor($model));
        }

        return $models;
    }
707998
public function addRelationSelectColumns($relation)
    {
        $join = $this->joins[$relation];
        $join->getTableMap()->addSelectColumns($this, $join->getRelationAlias());

        return $this;
    }
479021
public function orRelations(array $relations)
    {
        foreach ($relations as $column1 => $column2) {
            $this->orRelation($column1, $column2);
        }

        return $this;
    }
1213718
public function matchOne(array $models, array $results, $relation)
    {
        $dictionary = $this->buildDictionary($results);

        foreach ($models as $model) {
            $key = $model->getAttribute($this->localKey);

            if (isset($dictionary[$key])) {
                $value = $this->getRelationValue($dictionary, $key, 'one');

                $model->setRelation($relation, $value);
            }
        }

        return $models;
    }
827950
public function syncRelationships(array $relationships)
    {
        foreach ($relationships as $relation) {
            if (in_array($relation, $this->needSync)) {
                $this->synchronize($relation);
            }
        }
    }
252522
protected function createRelatedEntities($relations)
    {
        $entitiesToCreate = $this->aggregate->getNonExistingRelated($relations);

        foreach ($entitiesToCreate as $aggregate) {
            $this->createStoreCommand($aggregate)->execute();
        }
    }
507828
public function withCount($relations)
    {
        if (is_string($relations)) $relations = func_get_args();

        // If no columns are set, add the default * columns.
        if (is_null($this->query->columns)) {
            $this->query->select($this->query->from .'.*');
        }

        $relations = $this->parseRelations($relations);

        foreach ($relations as $name => $constraints) {
            $segments = explode(' ', $name);

            if ((count($segments) == 3) && (Str::lower($segments[1]) == 'as')) {
                list($name, $alias) = array($segments[0], $segments[2]);
            } else {
                unset($alias);
            }

            $relation = $this->getHasRelationQuery($name);

            // Here we will get the relationship count query and prepare to add it to the main query
            // as a sub-select. First, we'll get the "has" query and use that to get the relation
            // count query. We will normalize the relation name then append _count as the name.
            $query = $relation->getRelationCountQuery($relation->getRelated()->newQuery(), $this);

            call_user_func($constraints, $query);

            $this->mergeWheresToHas($query, $relation);

            $asColumn = snake_case(isset($alias) ? $alias : $name) .'_count';

            $this->selectSub($query->getQuery(), $asColumn);
        }

        return $this;
    }