LMongo\Eloquent\Builder::getRelation PHP Method

getRelation() public method

Get the relation instance for the given relation name.
public getRelation ( string $relation ) : Relation
$relation string
return LMongo\Eloquent\Relations\Relation
    public function getRelation($relation)
    {
        $query = $this->getModel()->{$relation}();
        // If there are nested relationships set on the query, we will put those onto
        // the query instances so that they can be handled after this relationship
        // is loaded. In this way they will all trickle down as they are loaded.
        $nested = $this->nestedRelations($relation);
        if (count($nested) > 0) {
            $query->getQuery()->with($nested);
        }
        return $query;
    }