Query with eager loading.

@param array $relations

@return static
430556
public function with(array $relations)
    {
        $this->with = array_unique(array_merge($this->with, $relations));

        return $this;
    }
684891
public function get($columns = ['*'])
    {
        $builder = $this->prepareQueryBuilder($columns);

        $models = $builder->getModels();

        // If we actually found models we will also eager load any relationships that
        // have been specified as needing to be eager loaded. This will solve the
        // n + 1 query problem for the developer and also increase performance.
        if (count($models) > 0) {
            $models = $builder->eagerLoadRelations($models);
        }

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

        return $this;
    }
340894
public static function with($relations)
    {
        if (is_string($relations)) $relations = func_get_args();

        $instance = new static;

        return $instance->newQuery()->with($relations);
    }
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;
    }
579967
protected function parseRelations(array $relations)
	{
		$results = array();

		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))
			{
				$f = function() {};

				list($name, $constraints) = array($constraints, $f);
			}

			// 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->parseNested($name, $results);

			$results[$name] = $constraints;
		}

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

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

        return $instance;
    }
1134821
def with_(self, *relations):
        
        if not relations:
            return self

        eagers = self._parse_relations(list(relations))

        self._eager_load.update(eagers)

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

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

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

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

        return $this;
    }
926408
public function havingRelations(array $relations)
    {
        $instance = $this->havingStrategyInstance();

        $instance->havingStrategy()->havingRelations($relations);

        return $instance;
    }
1003883
public function scopeWithout($query, $relations)
    {
        $relations = is_array($relations) ? $relations : array_slice(func_get_args(), 1);
        $relationships = array_dot($query->getEagerLoads());
        foreach ($relations as $relation) {
            unset($relationships[$relation]);
        }

        return $query->setEagerLoads([])->with(array_keys($relationships));
    }
896236
public function include($relations):SuccessResponseBuilder
    {
        if (is_string($relations)) {
            $relations = explode(',', $relations);
        }

        $this->relations = array_merge($this->relations, (array) $relations);

        return $this;
    }
996468
protected function getRelationMethods(array $relations, array $fields)
    {
        $methods = [];

        foreach ($fields as $field) {
            if ($field->hasForeignRelation()) {
                $relation = $field->getForeignRelation();
                $methods[$relation->name] = $this->getRelationshipMethod($relation);
            }
        }

        foreach ($relations as $relation) {
            $methods[$relation->name] = $this->getRelationshipMethod($relation);
        }

        return $methods;
    }
207642
protected function fetchRelation(array $relation)
    {
        /* a relation is of the form
         * [$type, $foreign_class, $foreign_column, $column]
         */
        list($type, $foreign_class, $foreign_column, $column) = $relation;

        switch ($type) {
        case 'has_one':
            return $this->fetchOneToOne($foreign_class, $foreign_column, $column);
        case 'belongs_to':
            return $this->fetchOneToOne($foreign_class, $foreign_column, $column);
        case 'has_many':
            return $this->fetchOneToMany($foreign_class, $foreign_column, $column);
        default:
        }
    }
109150
public function withCount($relations) {
        if (empty($relations)) {
            return $this;
        }

        if (empty($this->selects)) {
            $this->select();
        }

        $relations = is_array($relations) ? $relations : func_get_args();

        foreach ($this->parseWithRelations($relations) as $name => $constraints) {
            // First we will determine if the name has been aliased using an "as" clause on the name
            // and if it has we will extract the actual relationship name and the desired name of
            // the resulting column. This allows multiple counts on the same relationship name.
            $segments = explode(' ', $name);

            $alias = null;

            if (count($segments) == 3 && strtolower($segments[1]) == 'as') {
                list($name, $alias) = [$segments[0], $segments[2]];
            }

            $relation = $this->getRelationWithoutConstraints($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->getRelationExistenceCountQuery(
                $relation->getRelated()->query(), $this
            );

            // Finally we will add the proper result column alias to the query and run the subselect
            // statement against the query builder. Then we will return the builder instance back
            // to the developer for further constraint chaining that needs to take place on it.
            $column = $alias ?: strtolower($name.'_count');

            $this->selectSub($query->getSql(), $column);
        }

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

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

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

		$this->loadQueue();
	}