Get the relation instance for the given relation name.

@param  string $name
@return \Illuminate\Database\Eloquent\Relations\Relation
435468
public function getRelation($name)
    {
        // We want to run a relationship query without any constrains so that we will
        // not have to remove these where clauses manually which gets really hacky
        // and error prone. We don't want constraints because we add eager ones.
        $relation = Relation::noConstraints(function () use ($name) {
            $instance = $this->getModel()->newInstance();
            if (method_exists($instance, $name)) {
                return $instance->$name();
            }

            if ($relation = $instance->getRelationshipFromConfig($name)) {
                return $relation;
            }

            throw new RuntimeException("Call to undefined relationship [{$name}] on resource [{$this->getModel()->getTable()}].");
        });

        $nested = $this->relationsNestedUnder($name);

        // 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.
        if (count($nested) > 0) {
            $relation->getQuery()->with($nested);
        }

        return $relation;
    }
14468
public function getRelation($name) {
        // We want to run a relationship query without any constrains so that we will
        // not have to remove these where clauses manually which gets really hacky
        // and error prone. We don't want constraints because we add eager ones.
        $relation = Relation::noConstraints(function () use ($name) {
            try {
                return $this->getModel()->{$name}();
            } catch (\Exception $e) {
                throw $e;//RelationNotFoundException::make($this->getModel(), $name);
            }
        });

        $nested = $this->relationsNestedUnder($name);

        // 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.
        if (count($nested) > 0) {
            $relation->getQuery()->with($nested);
        }

        return $relation;
    }
515057
public function getRelationship($name, $strict = false)
	{
		if ($this->hasRelationship($name))
			return $this->_relationships[$name];

		if ($strict)
			throw new RelationshipException("Relationship named $name has not been declared for class: {$this->class->getName()}");

		return null;
	}
960117
protected static function _relations($type = null, $name = null) {
		$self = static::_object();

		if ($name) {
			if (isset($self->_relationsToLoad[$name])) {
				$t = $self->_relationsToLoad[$name];
				unset($self->_relationsToLoad[$name]);
				return static::bind($t, $name, (array) $self->{$t}[$name]);
			}
			return isset($self->_relations[$name]) ? $self->_relations[$name] : null;
		}
		if (!$type) {
			foreach ($self->_relationsToLoad as $name => $t) {
				static::bind($t, $name, (array) $self->{$t}[$name]);
			}
			$self->_relationsToLoad = [];
			return $self->_relations;
		}
		foreach ($self->_relationsToLoad as $name => $t) {
			if ($type === $t) {
				static::bind($t, $name, (array) $self->{$t}[$name]);
				unset($self->_relationsToLoad[$name]);
			}
		}
		return array_filter($self->_relations, function($i) use ($type) {
			return $i->data('type') === $type;
		});
	}
1144644
public static function oneByName($name)
	{
		$model = self::all()
			->whereEquals('name', $name)
			->row();

		if (!$model)
		{
			$model = self::blank();
		}

		return $model;
	}
807632
public function getRelation($name)
    {
        if (!isset($this->relationships)) {
            $relations = $this->getRelations();
        } else {
            $relations = $this->relationships;
        }

        foreach ($relations as $relation) {
            if ($relation->getAlias() == $name) {
                return $relation;
            }
        }
        return false;
    }
945301
public function getRelationship(string $name): array
    {
        if (array_key_exists($name, $this->relationships)) {
            return $this->relationships[$name];
        }

        return [];
    }
238550
public function getChildRelationship($name)
    {
        return $this->getChildRelationships()->filter(function($input) use ($name) {
            return $name === $input->getRelationshipName();
        })->first();
    }
394852
protected function getter($name)
    {
        $value = parent::getter($name);
        $name = $this->getProperty($name);
        if (null == $value) {
            $relMap = EntityDescriptorRegistry::getInstance()
                ->getDescriptorFor(get_class($this))
                ->getRelationsMap();
            if ($relMap->containsKey($name)) {
                $value = $relMap->get($name)->load($this);
            }
        }
        return $value;
    }
742467
public function getHasManyByRelationName($name)
    {
        if ($table = $this->getReferencingTable($name)) {
            if ($model = static::getModelFromTable($table)) {
                $refField = $this->getReferencingField($table, $name);

                return $this->hasMany($model, $refField);
            }
        }

        return null;
    }
805080
public static function getInstance($name)
    {
        if (!isset(static::$instances[$name])) {
            static::$instances[$name] = new CacheInstance();
        }
        return static::$instances[$name];
    }
122104
protected function getConnectionByName($name)
    {
        if (array_key_exists($name, $this->connectionByName)) {
            return $this->connectionByName[$name];
        }

        $event = clone $this->getManagerRegistryResourceEventPrototype();
        $event->setName(ManagerRegistryResourceEvent::RESOLVE_CONNECTION_EVENT);
        $event->setResourceName($name);
        $event->setTarget($this);


        $resultsEvent = $this->getEventManager()->trigger($event, function ($connection) {
            return is_object($connection);
        });

        $connection = $resultsEvent->last();

        if (!is_object($connection)) {
            $errMsg = sprintf('Connection %s not found', $name);
            throw new Exception\ConnectionNotFoundException($errMsg);
        }

        $this->connectionByName[$name] = $connection;

        return $this->connectionByName[$name];
    }
475723
public function get(string $relation): RelationInterface
    {
        if (isset($this->relations[$relation]) && $this->relations[$relation] instanceof RelationInterface) {
            return $this->relations[$relation];
        }

        $instance = $this->orm->makeRelation($this->class, $relation);
        if (array_key_exists($relation, $this->relations)) {
            //Indicating that relation is loaded
            $instance = $instance->withContext($this->parent, true, $this->relations[$relation]);
        } else {
            //Not loaded relation
            $instance = $instance->withContext($this->parent, false);
        }

        return $this->relations[$relation] = $instance;
    }
1300756
public static function get($name = 'default')
    {
        if (!isset(self::$connections[$name])) {
            return null;
        }

        $connector = self::$connections[$name];

        return $connector->connection();
    }
1102665
public static function getInstance( $name )
    {
        if (! isset( self::$instances[$name] ) )
            self::$instances[$name] = new self( $name );

        return self::$instances[$name];
    }
948528
protected function _getInstance($name)
    {
        $this->loadModel('Field.FieldInstances');
        $instance = $this->FieldInstances
            ->find()
            ->contain(['EavAttribute'])
            ->where(['EavAttribute.name' => $name])
            ->first();

        if (!$instance) {
            $this->_error(__d('field', 'Invalid field instance.'), 504);
        }

        return $instance;
    }
409580
public function getAdminConnection($name = null)
    {
        if (null === $name) {
            $name = $this->getDefaultConnectionName();
        }

        $serviceName = sprintf('doctrine_phpcr.admin.%s_session', $name);

        $connections = $this->getConnectionNames();
        if (!isset($connections[$name])) {
            throw new \InvalidArgumentException(sprintf('Doctrine %s Connection named "%s" does not exist.', $this->getName(), $name));
        }

        return $this->getService($serviceName);
    }