Check the existence of an actual relationship.

@param string $relation

@return bool
189102
protected function isActualRelationships(string $relation): bool
    {
        return array_key_exists($relation, $this->relationships)
            && count($this->relationships[$relation]) > 0;
    }
800304
protected function hasOneOrManyDeepFromRelations(array $relations)
    {
        if (is_array($relations[0])) {
            $relations = $relations[0];
        }

        $related = null;
        $through = [];
        $foreignKeys = [];
        $localKeys = [];

        foreach ($relations as $i => $relation) {
            $method = $this->hasOneOrManyDeepRelationMethod($relation);

            [$through, $foreignKeys, $localKeys] = $this->$method($relation, $through, $foreignKeys, $localKeys);

            if ($i === count($relations) - 1) {
                $related = get_class($relation->getRelated());
            } else {
                $through[] = get_class($relation->getRelated());
            }
        }

        return [$related, $through, $foreignKeys, $localKeys];
    }
673484
public static function transformSuspendToNormal($relation)
    {
        if (!($relation instanceof static) || $relation->getIsNewRecord() ||
                $relation->relationType != static::$relationMutual) {
            return false;
        }
        $new = static::buildNormalRelation($relation->initiator, $relation->recipient);
        return $new->save() && $relation->refresh();
    }
37289
public function has($relation, $operator = '>=', $count = 1, $boolean = 'and', Closure $callback = null)
    {
        if (strpos($relation, '.') !== false) {
            return $this->hasNested($relation, $operator, $count, $boolean, $callback);
        }

        $relation = $this->getHasRelationQuery($relation);

        $query = $relation->getRelationCountQuery($relation->getRelated()->newQuery(), $this);

        if ($callback) call_user_func($callback, $query);

        return $this->addHasWhere($query, $relation, $operator, $count, $boolean);
    }
960573
public function getRelationSavingModels($relation)
    {
        $result = isset($this->savingModels[$relation])
            ? $this->savingModels[$relation]
            : $this->owner->$relation;
        return is_array($result) && (!$this->owner->getRelation($relation)->multiple)
            ? reset($result) : $result;
    }
793578
public function hasRelation(String $label) : Bool
	{
		if (isset($this->relations[$label])) {
			return true;
		}

		return false;
	}
390625
protected function addNonProxyRelation(string $relation)
    {
        if (!in_array($relation, $this->nonProxyRelationships)) {
            $this->nonProxyRelationships[] = $relation;
        }
    }
1097045
protected function isNestedUnder($relation, $name)
    {
        return Str::contains($name, '.') && Str::startsWith($name, $relation.'.');
    }
325878
protected function isNested( $name, $relation )
	{
		$dots = Str::contains( $name, '.' );

		return $dots && Str::startsWith( $name, $relation . '.' );
	}
97818
public function removeRel($relation)
        {
            if (isset($this->_rel[$relation])) {
                unset($this->_rel[$relation]);
            }

            return $this;
        }
563722
private function checkHasOneRelation($entity, $relation)
    {
        $objectHashId     = $this->entityRegistry->getObjectHashId($entity);
        $varObjName       = $relation->varObjectName();
        $varReferenceName = $relation->varReferenceName();

        $currentRelation  = $this->getValue($entity, $varObjName);
        $originalRelation = $this->getValue($this->entityRegistry->getOriginal($entity), $varObjName);

        if (empty($currentRelation)) {
            // Current entity has no relation
            if (!empty($originalRelation)) {
                // Original had a relation, so relation was removed
                $this->scheduleForDeletion($originalRelation);
            }

            return;
        }

        // Current entity has a relation
        $currentRelationHash = $this->entityRegistry->getObjectHashId($currentRelation);

        if (isset($this->scheduledForDeletion[$objectHashId]) && $relation->cascadeDelete()) {
            $this->scheduleForDeletion($currentRelation);
        }

        if (empty($originalRelation)) {
            // Original had no relation, so relation was newly created
            $this->scheduleRelationForInsertion($entity, $currentRelation, $varReferenceName);

            return;
        }

        $originalRelationHash = $this->entityRegistry->getObjectHashId($originalRelation);

        if ($currentRelationHash != $originalRelationHash) {
            // Relation was exchanged
            $this->scheduleForDeletion($originalRelation);
            $this->scheduleRelationForInsertion($entity, $currentRelation, $varReferenceName);
        }
    }
560661
protected function addPolymorphicRelation(string $relation)
    {
        if (!in_array($relation, $this->polymorphicRelations)) {
            $this->polymorphicRelations[] = $relation;
        }
    }
515693
public function getLocalKeys($relation)
    {
        return isset($this->localForeignKeys[$relation]) ? $this->localForeignKeys[$relation] : null;
    }
664150
protected function getEntityHashesFromRelation(string $relation): array
    {
        return array_map(function (Aggregate $aggregate) {
            return $aggregate->getEntityHash();
        }, $this->relationships[$relation]);
    }
653619
protected function hasOneOrManyDeepRelationMethod(Relation $relation)
    {
        $classes = [
            BelongsTo::class,
            HasManyDeep::class,
            HasManyThrough::class,
            MorphOneOrMany::class,
            HasOneOrMany::class,
            MorphToMany::class,
            BelongsToMany::class,
        ];

        foreach ($classes as $class) {
            if ($relation instanceof $class) {
                return 'hasOneOrManyDeepFrom'.class_basename($class);
            }
        }

        throw new RuntimeException('This relationship is not supported.'); // @codeCoverageIgnore
    }
698533
protected function getCount(Relation $relation)
    {
        if ( ! $relation) return 0;

        $query = $this->modifyRelationQueryForContext($relation->getRelated(), $relation->getQuery());

        return $query->count();
    }
901785
public function addCloneableRelation($relation) {
		$relations = $this->getCloneableRelations();
		if (in_array($relation, $relations)) return;
		$relations[] = $relation;
		$this->cloneable_relations = $relations;
	}