Get the relation instance for the given relation name.

@param  string  $name
@return \Illuminate\Database\Eloquent\Relations\Relation
497457
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()->newInstance()->$name();
            } catch (BadMethodCallException $e) {
                throw 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;
    }
945301
public function getRelationship(string $name): array
    {
        if (array_key_exists($name, $this->relationships)) {
            return $this->relationships[$name];
        }

        return [];
    }
1063351
protected function getReferencingModel($name)
    {
        if (!$this->isRelationMapped($name)) {
            return null;
        }

        $table = $this->getReferencingTable($name);
        $model = static::getModelFromTable($table);

        return $model;
    }
930137
public static function getInstance($name)
	{
		$model = sprintf('\\%sAdmin', Str::studly($name));
		$model = new $model;

		return $model;
	}
1220361
public function getRelation($name)
    {
        return isset($this->metadata[Metadata::RELATIONS][$name]) ? $this->metadata[Metadata::RELATIONS][$name] : null;
    }
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;
    }
206133
protected function overwriteExistingRelation($name)
    {
        if ($this->relations->isEmpty()) {
            return;
        }

        $this->relations = $this->relations->filter(
            function (Relation $relation) use ($name) {
                return $relation->getName() != $name;
            }
        );
    }
75702
public function getHasOneByRelationName($name)
    {
        if ($table = $this->getReferencingTable($name)) {
            if ($model = static::getModelFromTable($table)) {
                $refField = $this->getReferencingField($table, $name);

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

        return null;
    }
968987
public function getRelationshipField($name)
    {
        return $this->getRelationshipFields()->filter(function($field) use ($name) {
            return $name === $field->getName();
        })->first();
    }
356122
public static function getInstance($name)
    {
        if (is_null(self::$instance)) {
            $arr = explode('.', $name);
            $company = $arr[0];
            $type = $arr[1];
            $className = self::$map[$company][$type];
            self::$instance = new $className;
        }

        return self::$instance;
    }
910566
public function makeRelationship($name)
	{
		// See if the relationship already exists
		if (!$this->getRelationship($name))
		{
			// Get the child rows/row and set them back on the model as a relationship for future use
			$rows = call_user_func_array(array($this, $name), array())->rows();
			$this->addRelationship($name, $rows);
		}

		return $this;
	}
608585
public static function getInstance($name = 'default')
    {
        if (isset(static::$instances[$name])) {
            return static::$instances[$name];
        }

        $instance = new static();

        static::$instances[$name] = $instance;

        return $instance;
    }
826563
public function getConnection($name)
    {
        if (!$this->connectionSettings->has($name)) {
            throw new BadArgumentException('Connection with name ":name" not defined in configuration file ":file"', [
                'name' => $name, 'file' => ServiceLocator::instance()->getConfiguration()->getIdentity(),
            ]);
        }
        
        $this->connect($name);
        
        return static::$connections[$name];
    }
866813
public function relation($relationName) {
		if(!$this->dataMapper->hasRelation($this->definition, $relationName))
			throw new \Exception('Relation '.$relationName.' does not exist.');
		$relation = $this->dataMapper->relation($this->definition, $relationName);
		$reverseRelation = $relation->reverse();
		$reverseRelationName = $reverseRelation->get('name');
		$relation_entity = $relation->get('entity');

		$table = $this->getTable();
		$alias = $reverseRelationName;

		$c = clone $this;
		$c->applyScopes();

		$where = $this->processConditions($c->getWhere());
		$where = $this->updateConditions($where, $table, $alias);

		return $this->dataMapper->orm($relation_entity)
			->where($where)
			->join('innerjoin '.$reverseRelationName, $this->join);
	}
492117
public function connection($name = null)
    {
        $name = $name ?: 'default';

        if (isset($this->connections[$name])) {
            return $this->connections[$name];
        }

        return $this->connections[$name] = $this->configure(
            $this->resolve($name), $name
        );
    }
1298784
private function getRelationshipMethodName($name)
    {
        if (stripos($name, '-')) {
            $name = lcfirst(implode('', array_map('ucfirst', explode('-', $name))));
        }

        if (stripos($name, '_')) {
            $name = lcfirst(implode('', array_map('ucfirst', explode('_', $name))));
        }

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

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

        return $connector->connection();
    }