protected function associateBelongsTo(array &$formatters, BelongsTo $relation, $seeding) {
        $relatedClass = get_class($relation->getRelated());
        $foreignKey = $relation->{$this->getBelongsToForeignKeyNameMethod()}();

        // Skips dynamic relationships.
        if (!isset($this->columns[$foreignKey])) {
            return;
        }

        $alwaysAssociate = $this->columns[$foreignKey]->getNotnull() || !$seeding;

        $formatters[$foreignKey] = function ($model, $insertedPKs) use ($relatedClass, $alwaysAssociate) {
            if (!isset($insertedPKs[$relatedClass])) {
                return null;
            }

            if ($alwaysAssociate) {
                return $this->generator->randomElement($insertedPKs[$relatedClass]);
            }

            return $this->generator->optional()->randomElement($insertedPKs[$relatedClass]);
        };
    }