protected function mergeRelations(&$resource, $input)
    {
        $existingNames = [];

        foreach ($resource->relations as $relation) {
            $existingNames[] = $relation->getName();
        }
        $mergeRelations = 0;
        foreach ($input->relations as $relation) {
            $newRelation = ForeignRelationship::fromString($relation);

            if (is_null($newRelation)) {
                continue;
            }
            if (!empty($newRelation->name) && in_array($newRelation->name, $existingNames)) {
                $this->warn('The relation "' . $newRelation->name . '" already exists in the file.');
                continue;
            }

            $resource->relations[] = $newRelation;
            $existingNames[] = $newRelation->name;

            $mergeRelations++;
        }

        return $mergeRelations;
    }