protected function createBelongsToIdentity(Model $model, $relationshipKey)
    {
        $relation = $model->{$relationshipKey}();

        if (!$relation instanceof BelongsTo) {
            throw new RuntimeException(sprintf(
                'Expecting %s on %s to be a belongs-to relationship.',
                $relationshipKey,
                get_class($model)
            ));
        }

        // support Laravel 5.8
        $foreignKey = method_exists($relation, 'getForeignKeyName') ?
            $relation->getForeignKeyName() :
            $relation->getForeignKey();

        $id = $model->{$foreignKey};

        if (is_null($id)) {
            return null;
        }

        // support Laravel 5.8
        $ownerKey = method_exists($relation, 'getOwnerKeyName') ?
            $relation->getOwnerKeyName() :
            $relation->getOwnerKey();

        $related = $relation->getRelated()->replicate();
        $related->{$ownerKey} = $id;

        return $related;
    }