LMongo\Eloquent\Builder::parseRelations PHP Method

parseRelations() protected method

Parse a list of relations into individuals.
protected parseRelations ( array $relations ) : array
$relations array
return array
    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;
    }