Eager loads relations on the collection.

@param  string|array $includes Relation or array of relations to eager load
@return $this
325972
public function include($includes)
	{
		$items = $this->items;

		(function() use ($includes, $items): void
		{
			$this->including($includes)->loadIncludes($items);
		})->bindTo($this->items[0]->builder(), Query::class)();

		return $this;
	}
239776
public function load($data, $relations = [])
	{
		$this->clearQueue();

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

		$this->queueUnresolvedObjects($data, $relations);

		$this->loadQueue();
	}
1107086
protected function parseWithRelations(array $relations)
    {
        $results = [];

        foreach ($relations as $name => $constraints) {
            // If the "relation" value is actually a numeric key, we can assume that no
            // constraints have been specified for the eager load and we'll just put
            // an empty Closure with the loader so that we can treat all the same.
            if (is_numeric($name)) {
                $name = $constraints;

                list($name, $constraints) = Str::contains($name, ':')
                    ? $this->createSelectWithConstraint($name)
                    : [$name, function () {
                        //
                    }];
            }

            // We need to separate out any nested includes. Which allows the developers
            // to load deep relationships using "dots" without stating each level of
            // the relationship with its own key in the array of eager load names.
            $results = $this->addNestedWiths($name, $results);

            $results[$name] = $constraints;
        }

        return $results;
    }
1308048
public function load($relations = [])
	{
		$this->addRelations($relations);
		
		$this->clearQueue();

		$this->queueUnresolvedObjects($this->data, $this->relations);

		$this->loadQueue();
	}
611172
public function setRelations($relations)
    {
        $this->setAvailableIncludes(array_unique(array_merge($this->availableIncludes, (array) $relations)));

        return $this;
    }
186271
public function descendants($includeSelf = false, $depth = null)
    {
        $this
            ->getQuerySet()
            ->descendants($includeSelf, $depth);

        return $this;
    }
676361
private function extractInclusions(array $params)
    {
        if (false === $this->issetNotEmpty(self::PARAM_INCLUSIONS, $params)) {
            if (true === $this->config->includeAllByDefault()) {
                $this->inclusions = ['*' => true];
            }
            return $this;
        }
        $inclusions = explode(',', $params[self::PARAM_INCLUSIONS]);
        foreach ($inclusions as $inclusion) {
            if (false !== stristr($inclusion, '.')) {
                throw RestException::invalidParamValue(self::PARAM_INCLUSIONS, sprintf('Inclusion via a relationship path, e.g. "%s" is currently not supported.', $inclusion));
            }
            $this->inclusions[$inclusion] = true;
        }
        return $this;
    }
245543
public function excluding($excludes)
	{
		if($excludes === true)
		{
			$this->model->setIncludes([]);
		}
		else
		{
			$excludes = (array) $excludes;

			$includes = $this->model->getIncludes();

			foreach($excludes as $key => $relation)
			{
				if(is_string($relation) && isset($includes[$relation]))
				{
					unset($includes[$relation], $excludes[$key]); // Unset relations that may have been set with a criterion closure
				}
			}

			$this->model->setIncludes(array_udiff($includes, $excludes, function($a, $b)
			{
				return $a === $b ? 0 : -1;
			}));
		}

		return $this;
	}
377401
public function loadCount($relations)
    {
        if ($this->isEmpty()) {
            return $this;
        }

        $models = $this->first()->newModelQuery()
            ->whereKey($this->modelKeys())
            ->select($this->first()->getKeyName())
            ->withCount(...func_get_args())
            ->get();

        $attributes = Arr::except(
            array_keys($models->first()->getAttributes()),
            $models->first()->getKeyName()
        );

        $models->each(function ($model) use ($attributes) {
            $this->find($model->getKey())->forceFill(
                Arr::only($model->getAttributes(), $attributes)
            )->syncOriginalAttributes($attributes);
        });

        return $this;
    }
687274
public function setRelations(array $relations): self
    {
        // Parse and set the relations.
        $this->relations = $this->newModelQuery()
            ->with($relations)
            ->getEagerLoads();

        return $this;
    }
1285173
protected function eagerLoadRelation(array $models, $name, Closure $constraints)
    {
        // First we will "back up" the existing where conditions on the query so we can
        // add our eager constraints. Then we will merge the wheres that were on the
        // query back to it in order that any where conditions might be specified.
        $relation = $this->getRelation($name);

        $relation->addEagerConstraints($models);

        $constraints($relation);

        // Once we have the results, we just match those back up to their parent models
        // using the relationship instance. Then we just return the finished arrays
        // of models which have been eagerly hydrated and are readied for return.
        return $relation->match(
            $relation->initRelation($models, $name),
            $relation->getEager(), $name
        );
    }
138521
protected static function expandWildcardedIncludes(array $includes)
    {
        if (empty($includes)) {
            return $includes;
        }
        $expandedIncludes = [];
        foreach ($includes as $include) {
            $expandedIncludes = array_merge($expandedIncludes, self::expandWildcardsFor($include));
        }
        return $expandedIncludes;
    }
1129536
public function with(array $related)
    {

        $relations = $this->getEntityObject()->getRelations();
        foreach ($relations as $fk => $target) {
            $table = strstr($target, '.', true);

            if (in_array($table, $related)) {

                $this->sql(" ,$table.*");
                $this->join($table, "$this->oosql_table.$fk = $target");
            } elseif (isset($related[$table])) {

                foreach ($related[$table] as $field) {
                    $this->sql(" ,$table.$field");
                }
                $this->join($table, "$this->oosql_table.$fk = $target");
            }
        }
        return $this;
    }
677837
public function setIncludes($includes)
    {
        if ($this->isReference()) {
            throw $this->tooManyAttributes();
        }
        if ($includes !== null && strlen($includes) > 0) {
            $tok = strtok($includes, ", ");
            while ($tok !== false) {
                $o = $this->createInclude();
                $o->setName($tok);
                $tok = strtok(", ");
            }
        }
    }
106679
public function loadAny()
    {
        if ($this->loaded()) {
            $this->unload();
        }
        $this->hook('beforeLoad', array('loadAny', array()));

        $this->controller->loadByConditions($this);

        $this->endLoad();

        return $this;
    }
240130
public function setReferences($references)
    {
        $this->_references = [];
        foreach ($references as $name => $ref) {
            if (!array_key_exists('key', $ref)) {
                $ref['key'] = 'id';
            }
            $this->_references[$name] = $ref;
        }
        return $this;
    }
1089640
protected function parseWithRelations(array $relations)
    {
        $results = [];

        foreach ($relations as $name => $constraints) {
            // If the "relation" value is actually a numeric key, we can assume that no
            // constraints have been specified for the eager load and we'll just put
            // an empty Closure with the loader so that we can treat all the same.
            if (is_numeric($name)) {
                $name = $constraints;

                list($name, $constraints) = (mb_strpos($name, ':') !== false)
                            ? $this->createSelectWithConstraint($name)
                            : [$name, function () {
                                //
                            }];
            }

            // We need to separate out any nested includes. Which allows the developers
            // to load deep relationships using "dots" without stating each level of
            // the relationship with its own key in the array of eager load names.
            $results = $this->addNestedWiths($name, $results);

            $results[$name] = $constraints;
        }

        return $results;
    }