Choose what relationships to return with query.

@param mixed $relationships
@return $this
558853
public function with($relationships)
    {
        $this->requiredRelationships = [];

        if ($relationships == 'all') {
            $this->requiredRelationships = $this->relationships;
        } elseif (is_array($relationships)) {
            $this->requiredRelationships = array_filter($relationships, function ($value) {
                return in_array($value, $this->relationships);
            });
        } elseif (is_string($relationships)) {
            array_push($this->requiredRelationships, $relationships);
        }

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

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

        return $this;
    }
1064638
private function resolveRelationships(array $relationshipsToProcess)
    {
        $iterator = new \ArrayIterator($relationshipsToProcess);
        while ($iterator->valid()) {
            $resolver = $iterator->current();
            if (is_callable($resolver) === false) {
                $iterator->next();
                continue;
            }
            $relationships = $resolver();

            foreach ($relationships as $relationship) {
                $iterator->append($relationship);
            }

            $iterator->next();
        }
    }
916288
protected function setModels($models): self
    {
        // We can not use the collect() helper here, since we require this
        // to be an Eloquent Collection
        $this->models = $models instanceof EloquentCollection
            ? $models
            : new EloquentCollection($models);

        return $this;
    }
793096
public function select($columns = "*")
    {
        $this->start = $columns;
        $this->queryType = self::QUERY_SELECT;
        return $this;
    }
45232
public function from($tables)
    {
        if (is_string($tables)) {
            $tables = $this->splitParts($tables);
        }
        foreach ($tables as $k => $table) {
            if ($alias = $this->matchAlias($table)) {
                $tables[$k] = $this->db->quoteTable($alias[0]) . ' AS ' . $this->db->quoteTable($alias[1]);
            } else {
                $tables[$k] = $this->db->quoteTable($table);
            }
        }

        $this->query['from'] = implode(', ', $tables);

        return $this;
    }
444891
public function getToManyRelationship(string $relationship): ToManyRelationship
    {
        $data = $this->getResource();

        if (isset($data["relationships"][$relationship]["data"]) === false) {
            throw $this->exceptionFactory->createRelationshipNotExistsException($relationship);
        }

        $resourceIdentifiers = [];
        foreach ($data["relationships"][$relationship]["data"] as $item) {
            $resourceIdentifiers[] = ResourceIdentifier::fromArray($item, $this->exceptionFactory);
        }

        return new ToManyRelationship($resourceIdentifiers);
    }
241062
public function whereRelations(array $relations)
    {
        $instance = $this->whereStrategyInstance();

        $instance->whereStrategy()->whereRelations($relations);

        return $instance;
    }
173424
protected function unionAllRelationQueries(Collection $relations): EloquentBuilder
    {
        return $relations
            ->reduce(
                function (EloquentBuilder $builder, Relation $relation) {
                    return $builder->unionAll(
                        $relation->getQuery()
                    );
                },
                // Use the first query as the initial starting point
                $relations->shift()->getQuery()
            );
    }
687274
public function setRelations(array $relations): self
    {
        // Parse and set the relations.
        $this->relations = $this->newModelQuery()
            ->with($relations)
            ->getEagerLoads();

        return $this;
    }
966549
public function with($relations)
    {
        $this->with = $relations;
        $this->fields = array_merge($this->fields, $this->with);
        return $this;
    }
461813
public static function parseRelationShips(string $relationships, &$results): array
    {
        $relationships = explode(',', $relationships);

        $newResults = [];

        //if its a list
        if ($results instanceof ResultsetInterface && count($results) >= 1) {
            foreach ($results as $key => $result) {
                //clean records conver to array
            $newResults[$key] = $result->toArray();
                foreach ($relationships as $relationship) {
                    if ($results[$key]->$relationship) {
                        $newResults[$key][$relationship] = $results[$key]->$relationship;
                    }
                }
            }
        } else {
            //if its only 1 record
            if ($results instanceof Model) {
                $newResults = $results->toArray();
                foreach ($relationships as $relationship) {
                    if ($results->$relationship) {
                        $newResults[$relationship] = $results->$relationship;
                    }
                }
            }
        }

        unset($results);
        return $newResults;
    }
791880
public function addRelationship(TermRelationships $relationship)
    {
        if (!$this->relationships->contains($relationship)) {
            $this->relationships[] = $relationship;
        }

        return $this;
    }
327249
public function whereSearch($filters)
    {
        foreach ($this->queries as $query) {
            $query->whereSearch($filters);
        }

        return $this;
    }
126953
public function addRelations($relations)
	{
		if(is_numeric($relations))
		{
			
			$relations = intval($relations);
			$this->relations = $relations;
		}
		else
		{
			$relations = ( is_array($relations) ) ? $relations : explode(',', strval($relations));
			foreach ($relations as $prop)
			{
				if( ! in_array($prop, $this->relations) )
				{
					$this->relations[] = trim($prop);
				}
			}
		}

		if($this instanceof Collection)
		{
			foreach ($this->data as $model)
			{
				$model->addRelations($this->relations);
			}
		}
	}
855086
public function with($relationship)
    {
        $this->_with[] = $relationship;

        if (!in_array('relate', $this->after_get))
        {
            $this->after_get[] = 'relate';
        }

        return $this;
    }
1059900
public function eagerLoadRelations(array $models)
	{
		foreach ($this->eagerLoad as $name => $constraints)
		{
			// For nested eager loads we'll skip loading them here and they will be set as an
			// eager load on the query to retrieve the relation so that they will be eager
			// loaded on that query, because that is where they get hydrated as models.
			if (strpos($name, '.') === false)
			{
				$models = $this->loadRelation($models, $name, $constraints);
			}
		}

		return $models;
	}