Retrieve a relationship object for this table. Strict as true will throw an error
if the relationship name does not exist.

@param $name string name of Relationship
@param $strict bool
@throws RelationshipException
@return Relationship or null
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;
	}
520005
public function getHasManyField($name)
    {
        $field = $this->getField($name);

        return $field instanceof HasManyField ? $field : null;
    }
1224287
public function get($name = null)
    {
        if (!is_null($name)) {
            if (array_key_exists($name, $this->formats)) {
                return $this->formats[$name];
            }

            return false;

        } else {
            return $this->formats;
        }
    }
1207851
public static function getRelationDefinition($name)
    {
        if (!isset(static::$relations[$name])) {
            throw new \Exception(sprintf('Relation "%s" of Entity "%s" is not defined', $name, get_called_class()));
        }
        $relation = static::$relations[$name];
        if (count($relation) !== 4) {
            throw new \Exception(sprintf('Relation "%s" of Entity "%s" is invalid', $name, get_called_class()));
        }

        return $relation;
    }
125121
public function getConnection($name = 'default')
    {
        if (array_key_exists($name, $this->connections)) {
            return $this->connections[$name];
        }
        return null;
    }
442321
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 (BadMethodCallException $e) {
                throw new RuntimeException("Call to undefined relationship [".$name."] on model [".get_class($this->getModel())."].");
            }
        });

        $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;
    }
1305278
public function getForeignKey($name)
    {
        if (!$this->hasForeignKey($name)) {
            throw SchemaException::tableForeignKeyDoesNotExist($this->getName(), $name);
        }

        return $this->foreignKeys[$name];
    }
932685
private function relationshipImpl(string $name, bool $notNullable, bool $cascadeDelete): Closure
    {
        return function (
            Table $table,
            MigrationContextInterface $context
        ) use (
            $name,
            $notNullable,
            $cascadeDelete
        ) {
            $modelClass = $context->getModelClass();

            assert(
                $this->getModelSchemas()->hasRelationship($modelClass, $name),
                "Relationship `$name` not found for model `$modelClass`."
            );
            assert(
                $this->getModelSchemas()->getRelationshipType($modelClass, $name) === RelationshipTypes::BELONGS_TO,
                "Relationship `$name` for model `$modelClass` must be `belongsTo`."
            );

            $localKey     = $this->getModelSchemas()->getForeignKey($modelClass, $name);
            $columnType   = $this->getModelSchemas()->getAttributeType($modelClass, $localKey);
            $columnLength = $columnType === Type::STRING ?
                $this->getModelSchemas()->getAttributeLength($modelClass, $localKey) : null;

            $otherModelClass = $this->getModelSchemas()->getReverseModelClass($modelClass, $name);
            assert(
                $this->getModelSchemas()->hasClass($otherModelClass),
                "Class `$otherModelClass` is not found in model Schemas."
            );
            $foreignTable = $this->getModelSchemas()->getTable($otherModelClass);
            $foreignKey   = $this->getModelSchemas()->getPrimaryKey($otherModelClass);

            $fkClosure = $this->foreignColumnImpl(
                $localKey,
                $foreignTable,
                $foreignKey,
                $columnType,
                $columnLength,
                $notNullable,
                $cascadeDelete
            );

            return $fkClosure($table);
        };
    }
1316986
public function findByName( $name )
    {

        // is this name schema qualified
        $call = sprintf(
            "findBy%s",
            ( false !== strpos( $name, '.' ) ) ? 'FullyQualifiedName' : 'Name'
        );

        $found = $this->persistedGet()->$call( $name );

        // return
        switch( $count = count( $found ) ) {
            case 0:
                return null;
            case 1:
                return $found->pop();
            default:
                throw new \LogicException( "{$count} relations' found with name `{$name}`. Ambiguous. Can't proceed." );
        }

    }
423598
private function getRelated($name)
    {
        $relation = &static::$relations[$name];
        $class    = $relation[0];
        $FKName   = isset($relation[1]) ? $relation[1] : static::$PKFieldName[0];

        $related = &$this->related[$name];

        return $related === null
            ? $related = new $class($this->$FKName)
            : $related;
    }
262535
public function getNestedRelationships($name)
    {
        $pieces     = explode('.', $name);
        $models     = array();
        $num_pieces = sizeof($pieces);

        //iterate over the relationships to see if they're all valid
        foreach ($pieces as $i => $rel) {
            //if this is the first item, then the model is the config's model
            if ($i === 0) {
                $models[] = $this->config->getDataModel();
            }

            //if the model method doesn't exist for any of the pieces along the way, exit out
            if (!method_exists($models[$i], $rel) || !is_a($models[$i]->{$rel}(), self::BELONGS_TO)) {
                throw new \InvalidArgumentException("The '".$this->getOption('column_name')."' column in your ".$this->config->getOption('name').
                    " model configuration needs to be either a belongsTo relationship method name or a sequence of them connected with a '.'");
            }

            //we don't need the model of the last item
            $models[] = $models[$i]->{$rel}()->getRelated();
        }

        return array('models' => $models, 'pieces' => $pieces);
    }
238550
public function getChildRelationship($name)
    {
        return $this->getChildRelationships()->filter(function($input) use ($name) {
            return $name === $input->getRelationshipName();
        })->first();
    }
1125570
public function getOption(string $name, $default = null, $strict = null)
    {
        if (array_key_exists($name, $this->options)) {
            $value = $this->options[$name];

            // use strict, check value is empty ?
            if (true === $strict || (false !== $strict && $this->isStrict())) {
                $value = $value ?: $default;
            }

        } else {
            $value = $default;
        }

        if ($value && ($value instanceof \Closure)) {
            $value = $value();
        }

        return $value;
    }
1220361
public function getRelation($name)
    {
        return isset($this->metadata[Metadata::RELATIONS][$name]) ? $this->metadata[Metadata::RELATIONS][$name] : null;
    }
872593
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 is error prone while we remove the developer's own where clauses.
		$relation = Relation::noConstraints( function () use ( $name )
		{
			return $this->getModel()->$name();
		} );

		$nested = $this->nestedRelations( $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;
	}
442732
public function getRelationship($key)
    {
        if (isset($this->relationships[$key])) {
            return $this->relationships[$key];
        }
        return null;
    }
1239131
public function getValue(string $name)
	{
		if(array_key_exists($name, $this->columns))
		{
			// It's a database column

			return $this->getColumnValue($name);
		}
		elseif(array_key_exists($name, $this->related))
		{
			// The column is a cached or eagerly loaded relation

			return $this->related[$name];
		}
		elseif($this->isRelation($name))
		{
			// The column is a relation. Lazy load the record(s) and cache them

			return $this->related[$name] = $this->$name()->getRelated();
		}

		// All options have been exhausted so we'll throw an exception

		throw new RuntimeException(vsprintf('Unknown column or relation [ %s ].', [$name]));
	}