Returns whether the relation's foreign keys were configured nullable.

@return bool|null    null if the nullabillity of the keys was not configured
482100
protected function explicitlyConfiguredForeignKeysNullable()
    {
        $nullable = array_get($this->formFieldData->options(), 'nullable_key');

        if (null === $nullable) return null;

        return (bool) $nullable;
    }
675100
public function lastKey()
    {
        $keys = AccessHelper::collectionKeys($this->data);

        if (empty($keys) || end($keys) === false) {
            return null;
        }

        return end($keys);
    }
217767
public function getOtherFks()
    {
        $fks = [];
        foreach ($this->parentTable->getForeignKeys() as $fk) {
            if ($fk !== $this) {
                $fks[]= $fk;
            }
        }

        return $fks;
    }
1122898
public function checkMandatoryKey()
    {
        foreach ($this->mandatoryKeys as $key) {
            if (!array_key_exists($key, $this)) {
                return $key;
            }
        }

        return true;
    }
690353
public function isOk()
    {
        if (null === $this->multiplicity) {
            return false;
        }
        $relName = $this->relationName;
        if (null === $relName || !is_string($relName) || empty($relName)) {
            return false;
        }
        $keyField = $this->keyField;
        if (null === $keyField || !is_string($keyField) || empty($keyField)) {
            return false;
        }
        $baseType = $this->baseType;
        if (null === $baseType || !is_string($baseType) || empty($baseType)) {
            return false;
        }
        $targType = $this->targType;
        if ($this instanceof AssociationStubMonomorphic && null === $targType) {
            return false;
        }
        if (null !== $targType && (!is_string($targType) || empty($targType))) {
            return false;
        }
        $foreignField = $this->foreignField;
        if (null !== $targType && (null === $foreignField || !is_string($foreignField) || empty($foreignField))) {
            return false;
        }
        return (null === $targType) === (null === $foreignField);
    }
961614
protected function getNullForeignKeyFromRelation(string $relation): array
    {
        $key = $this->entityMap->getLocalKeys($relation);

        if (is_array($key)) {
            return $this->entityMap->getEmptyValueForLocalKey($relation);
        }

        if (is_null($key)) {
            throw new MappingException("Foreign key for relation $relation cannot be null");
        }

        return [
            $key => $this->entityMap->getEmptyValueForLocalKey($relation),
        ];
    }
820116
public function getPrimaryKey(){
		$table = $this->getTable();
		if(!$table)
			return null;
		$key = null;
		$cached = $this->connection->getCache()->fetch($table . '_primaryKey');

		if($cached === null){
			try{
				$key = $this->connection->getDriver()
					->getPrimaryKey($table, isset($this->resultSet) ? $this->resultSet : null);
			} catch(NeevoException $e){
				return null;
			}
			$this->connection->getCache()->store($table . '_primaryKey', $key);
			return $key === '' ? null : $key;
		}
		return $cached === '' ? null : $cached;
	}
224635
public function unlink($id = null): bool
	{
		$query = $this->junction()->where($this->getForeignKey(), '=', $this->parent->getPrimaryKeyValue());

		if($id !== null)
		{
			$query->in($this->getJunctionKey(), $this->getJunctionKeys($id));
		}

		return (bool) $query->delete();
	}
1152509
protected function getOtherKey()
    {
        if ($this->otherKey) {
            return $this->otherKey;
        }

        if (is_callable([$this->form->model(), $this->column]) &&
            ($relation = $this->form->model()->{$this->column}()) instanceof BelongsToMany
        ) {
            /* @var BelongsToMany $relation */
            $fullKey = $relation->getQualifiedRelatedPivotKeyName();
            $fullKeyArray = explode('.', $fullKey);

            return $this->otherKey = end($fullKeyArray);
        }

        throw new \Exception('Column of this field must be a `BelongsToMany` relation.');
    }
611670
private function isRelated()
    {
        $isRelated = false;
        $idSuffix = '_id';
        $pos = strrpos($this->key, $idSuffix);

        if ($pos !== false
            && strlen($this->key) - strlen($idSuffix) === $pos
        ) {
            $isRelated = true;
        }

        return $isRelated;
    }
1347059
protected function isKeyAllowed($key)
    {
        /*
         * Let the core columns through
         */
        if ($key == 'id' || $key == 'value' || $key == 'item') {
            return true;
        }

        /*
         * Let relations through
         */
        if ($this->model->hasRelation($key)) {
            return true;
        }

        return false;
    }
954969
public function hasOne($related, $foreignKey = null, $localKey = null)
    {
        if (is_array($foreignKey)) { //Check for multi-columns relationship
            $this->validateRelatedModel($related);
        }

        $instance = $this->newRelatedInstance($related);

        $foreignKey = $foreignKey ?: $this->getForeignKey();

        $foreignKeys = null;

        if (is_array($foreignKey)) { //Check for multi-columns relationship
            foreach ($foreignKey as $key) {
                $foreignKeys[] = $this->sanitizeKey($instance, $key);
            }
        } else {
            $foreignKey = $this->sanitizeKey($instance, $foreignKey);
        }

        $localKey = $localKey ?: $this->getKeyName();

        return new HasOne($instance->newQuery(), $this, $foreignKeys ?: $foreignKey, $localKey);
    }
1254938
public function ownedBy(Model $related = null, ?string $key = null): bool
    {
        if (\is_null($related)) {
            return false;
        }

        if (\is_null($key)) {
            $key = $related->getForeignKey();
        }

        return $this->getAttribute($key) == $related->getKey();
    }
876018
public function onRelationManageRemove()
    {
        $this->beforeAjax();

        $recordId = post('record_id');
        $sessionKey = $this->deferredBinding ? $this->relationGetSessionKey() : null;
        $relatedModel = $this->relationModel;

        /*
         * Remove
         */
        if ($this->viewMode == 'multi') {

            $checkedIds = $recordId ? [$recordId] : post('checked');

            if (is_array($checkedIds)) {
                $foreignKeyName = $relatedModel->getKeyName();

                $models = $relatedModel->whereIn($foreignKeyName, $checkedIds)->get();
                foreach ($models as $model) {
                    $this->relationObject->remove($model, $sessionKey);
                }
            }
        }
        /*
         * Unlink
         */
        elseif ($this->viewMode == 'single') {
            if ($this->relationType == 'belongsTo') {
                $this->relationObject->dissociate();
                $this->relationObject->getParent()->save();
            }
            elseif ($this->relationType == 'hasOne' || $this->relationType == 'morphOne') {
                if ($obj = $relatedModel->find($recordId)) {
                    $this->relationObject->remove($obj, $sessionKey);
                }
                elseif ($this->viewModel->exists) {
                    $this->relationObject->remove($this->viewModel, $sessionKey);
                }
            }

            $this->viewWidget->setFormValues([]);
        }

        return $this->relationRefresh();
    }
527215
public function checkPrimaryKey()
    {
        if (($retval = $this->checkPrimaryConstraint())) {
            if ($this->is_translation) {
                $this->table_field_id = NABU_LANG_FIELD_ID;
            } else {
                $keys = $this->getStorageDescriptor()->getPrimaryConstraintFieldNames();
                $size = count($keys);
                if ($size > 0) {
                    $this->table_field_id = $keys[$size - 1];
                } else {
                    $this->table_field_id = null;
                    $this->is_translation = false;
                }
            }
        } else {
            $this->table_field_id = null;
            $this->is_translation = false;
        }

        return $retval;
    }
854580
private function relationData()
    {
        $onData = collect($this->data)->reject(function ($value, $key) {
            return !str_contains($key, 'on');
        });

        $foreignKeys = collect($this->data)->reject(function ($value, $key) {
            return !str_contains($key, 'tbl');
        });

        $this->onData = array_values($onData->toArray());

        $this->foreignKeys = array_values($foreignKeys->toArray());
    }
557601
public function getRelationships(): array
    {
        return array_column(
            array_filter(array_map(function ($includeKey, $settings) {
                return $settings['relation'] ? [$includeKey, $settings['relation']] : null;
            }, array_keys($this->getIncludeMap()), array_values($this->getIncludeMap()))),
            1, 0
        );
    }