Get child relationship by name

@param string $name  Relationship name
@return ChildRelationship
546270
public function getChildRelationship($name)
    {
        $result = array_filter($this->getChildRelationships(), function($input) use ($name) {
            return $name === $input->getRelationshipName();
        });

        return reset($result);
    }
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;
    }
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;
    }
112339
public function getRelation($name, $use_alias = false)
    {
        if ($use_alias) {
            foreach ($this->relations as $relation) {
                if (0 === strcasecmp($name, $relation->getName($use_alias))) {
                    return $relation;
                }
            }
        } else {
            $key = strtolower($name);
            if (isset($this->relations[$key])) {
                return $this->relations[$key];
            }
        }

        return null;
    }
902389
public function &__get($name)
	{
		try {
			return parent::__get($name);
		} catch (MemberAccessException $e) {
			if (isset($this->data[$name])) {
				return $this->data[$name];
			}
			throw $e;
		}

	}
1177405
public function get($name = null)
    {
        $parts = $this->_parseName($name);

        $child = $this;
        foreach ($parts as $part) {
            list($name) = $part;
            if (!isset($child->_children[$name])) {
                return;
            }
            $child = $child->_children[$name];
        }
        return $child;
    }
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;
    }
1001678
public function getChildren(string $name = ''): array
    {
        $nodes = [];

        foreach ($this->children as $node) {
            if (!$name || strcasecmp($node->getName(), $name) == 0) {
                $nodes[] = $node;
            }
        }

        return $nodes;
    }
950682
public function getByName($name)
    {
        return isset($this->names[$name]) ? $this->names[$name] : null;
    }
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;
    }
987988
public static function getConnection($name=null)
	{
		$config = Config::instance();
		$name = $name ? $name : $config->getDefaultConnection();

		if (!isset(self::$connections[$name]) || !self::$connections[$name]->connection)
			self::$connections[$name] = Connection::instance($config->getConnection($name));

		return self::$connections[$name];
	}
1061628
public static function fetchByName( $name )
    {
        $result = parent::fetchObject( self::definition(), null, array( 'name' => $name ) );
        return $result;
    }
361032
public function getChildByName($name) {
		foreach($this->getChildren() as $child) {
			if($child->getName() == $name) return $child;
		}

		return false;
	}
99183
public function children($name = null)
    {
        $child = $this->get($name);
        if (!$child) {
            return [];
        }
        return $child->_children;
    }
1268482
public function nameGetNextName($name) {
    $parentName = $this->parents[$name];
    if (!isset($parentName)) {
      $siblingNames = $this->toplevelNames;
      $siblingMap = $this->toplevelMap;
    }
    else {
      $siblingNames = $this->childNames[$parentName];
      $siblingMap = $this->childMap[$parentName];
    }
    $index = $siblingMap[$name];
    return isset($siblingNames[$index + 1])
      ? $siblingNames[$index + 1]
      : null;
  }
1132603
public function findChild($name) {
		foreach ($this->children as $child) {
			if ($child->name == $name) {
				return $child;
			}
		}

		return NULL;
	}
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." );
        }

    }