check if the relation is one to one.

@param $model object
@param $related string
335655
protected function isOneToMany($related, $model, $local, $remote)
    {
        return $this->getType(get_class($model), $related, $local, $remote) == OneToManyRelation;
    }
1157516
public static function getModelClass($model): string
    {
        if (!isset(self::$modelClassMap[$model])) {
            // try to detect
            $className = '\\Application\\' . $model . '\\Table';

            if (!class_exists($className)) {
                throw new RelationNotFoundException("Related class for model `$model` not found");
            }
            self::$modelClassMap[$model] = $className;
        }
        return self::$modelClassMap[$model];
    }
1252661
public function hasRelatedErrors($relationName = null)
    {
        if ($relationName === null) {
            foreach ($this->_relatedErrors as $errors) {
                if (!empty($errors)) {
                    return true;
                }
            }
            return false;
        } else {
            return !empty($this->_relatedErrors[$relationName]);
        }
    }
919865
public function setModel(Model $model)
    {
        if (strpos($this->originalName, '.') !== false) {
            $parts = explode('.', $this->originalName);
            $name = array_pop($parts);

            while ($parts) {
                $part = array_shift($parts);
                $relation = $model->getAttribute($part);

                if ($relation instanceof Model) {
                    $model = $relation;
                    $this->setName($name);
                }
            }
        }

        return parent::setModel($model);
    }
1107969
protected function getType($model, $related, $local, $remote)
    {
        $modelObject = new $model();
        $remoteObject = new $related();
        //
        $tablemodel = $this->getTable($modelObject);
        $tableremote = $this->getTable($remoteObject);
        //
        if (is_null($local) && is_null($remote)) {
            $model = $tablemodel.'_id';
            $remote = $tableremote.'_id';
        } else {
            $model = $remote;
        }
        //
        if (in_array(strtolower($model), $remoteObject->_columns)) {
            $this->relation = OneToOneRelation;
        }
        if (in_array(strtolower($remote), $modelObject->_columns)) {
            $this->relation = OneToManyRelation;
        }
        //
        return $this->relation;
    }
438852
protected function setForeignKeysToNull(Model $model, Relation $relation, array $keys)
    {
        if ( ! count($keys)) return;

        $key           = $this->normalizeForeignKey(head($keys));
        $model->{$key} = null;

        if (    count($keys) > 1
            &&  (   $relation instanceof MorphTo
                ||  $relation instanceof MorphOne
                ||  $relation instanceof MorphMany
            )
        ) {
            $key           = $this->normalizeForeignKey(array_values($keys)[1]);
            $model->{$key} = null;
        }

        $model->save();
    }
877313
public function hasOne($related, $parentKey = null, $localKey = null)
    {
        $parentKey = $parentKey ?: $this->getParentKey();
        $localKey = $localKey ?: $this->getKeyName();

        $instance = new $related;

        $relation = new Relations\Relation($instance, $this, $parentKey, $localKey);

        return $relation->find($localKey);
    }
638139
public function morphOne(Model $relatedModel, $morphName)
    {
        if ($relatedModel->isIgnored()) {
            return;
        }

        $this->relations->add(
            new Relations\MorphOne($this, $relatedModel, $morphName)
        );
    }
1091113
public function isMatchRelation($model, $result) {
        foreach ($this->links as $fk => $lk) {
            if ($model[$fk] != $result[$lk]) {
                return false;
            }
        }
        return true;
    }
1142053
protected function doSetSkillId(Picture $model, $relatedId) {
		if ($model->getSkillId() !== $relatedId) {
			$model->setSkillId($relatedId);

			return true;
		}

		return false;
	}
403650
private function deleteOneToManyRelations(\Tx_Oelib_Model $model)
    {
        $data = $model->getData();

        foreach ($this->relations as $key => $mapperName) {
            if ($this->isOneToManyRelationConfigured($key)) {
                $relatedModels = $data[$key];
                if (!is_object($relatedModels)) {
                    continue;
                }

                $mapper = \Tx_Oelib_MapperRegistry::get($mapperName);
                /** @var \Tx_Oelib_Model $relatedModel */
                foreach ($relatedModels as $relatedModel) {
                    $mapper->delete($relatedModel);
                }
            }
        }
    }
274466
public function belongsTo(Model $relatedModel, $foreignKey)
    {
        if ($relatedModel->isIgnored()) {
            return;
        }

        $this->relations->add(
            new Relations\BelongsTo($this, $relatedModel, $foreignKey)
        );
    }
814716
public static function initModel($model)
    {
        foreach(AnnotationManager::getPropertiesAnnotations(BeanFactory::getObjectClass($model), RelationBase::class) as $propertyName => $annotations)
        {
            if(null !== $model[$propertyName])
            {
                continue;
            }
            $annotation = $annotations[0];
            Query::init($model, $propertyName, $annotation);
        }
    }
1054459
protected function doSetFeaturedSkillId(Picture $model, $relatedId) {
		if ($model->getPictureId() !== $relatedId) {
			$model->setPictureId($relatedId);

			return true;
		}

		return false;
	}
1372244
public function setValue(Model $model)
    {
        if ($this->relation) {
            if (!$relationValue = $model->{$this->relation}) {
                return $this;
            }

            $this->value = $relationValue;
        } else {
            $this->value = $model->getAttribute($this->name);
        }

        return $this;
    }
308511
public function ini($related, $model, $local = null, $remote = null)
    {
        $this->setCurrent($model);
        $this->checkModels($related);
        //
        if ($this->isOneToOne($related, $model, $local, $remote)) {
            return $this->prepare($this->OneToOne($related, $model, $local, $remote));
        } elseif ($this->isOneToMany($related, $model, $local, $remote)) {
            return $this->prepare($this->OneToMany($related, $model, $local, $remote));
        }
    }
1061792
public function is_related($query) {
        if (parent::is_related($query)) {
            return true;
        }
        if (!$this->load_choices()) {
            return false;
        }
        foreach ($this->choices as $key=>$value) {
            if (strpos(core_text::strtolower($key), $query) !== false) {
                return true;
            }
            if (strpos(core_text::strtolower($value), $query) !== false) {
                return true;
            }
        }
        return false;
    }