protected function mergeFields(&$resource, $input)
    {
        $existingNames = Collect($resource->fields)->pluck('name')->all();
        $fields = FieldTransformer::fromString($this->option('fields'), 'generic', $input->translationFor);
        $mergeFields = 0;
        foreach ($fields as $field) {
            if (in_array($field->name, $existingNames)) {
                $this->warn('The field "' . $field->name . '" already exists in the file.');
                continue;
            }

            $existingNames[] = $field->name;
            $resource->fields[] = $field;
            $mergeFields++;
        }

        return $mergeFields;
    }
protected function mergeFields(&$resource, $input)
    {
        $existingNames = Collect($resource->fields)->pluck('name')->all();
        $fields = FieldTransformer::fromString($this->option('fields'), 'generic', $input->translationFor);
        $mergeFields = 0;
        foreach ($fields as $field) {
            if (in_array($field->name, $existingNames)) {
                $this->warn('The field "' . $field->name . '" already exists in the file.');
                continue;
            }

            $existingNames[] = $field->name;
            $resource->fields[] = $field;
            $mergeFields++;
        }

        return $mergeFields;
    }
protected function mergeFields ( & $ resource , $ input ) { $ existingNames = Collect ( $ resource -> fields ) -> pluck ( 'name' ) -> all ( ) ; $ fields = FieldTransformer :: fromString ( $ this -> option ( 'fields' ) , 'generic' , $ input -> translationFor ) ; $ mergeFields = 0 ; foreach ( $ fields as $ field ) { if ( in_array ( $ field -> name , $ existingNames ) ) { $ this -> warn ( 'The field "' . $ field -> name . '" already exists in the file.' ) ; continue ; } $ existingNames [ ] = $ field -> name ; $ resource -> fields [ ] = $ field ; $ mergeFields ++ ; } return $ mergeFields ; }
Merges the given file's content to the new fields.

@param CrestApps\CodeGenerator\Models\Resource &$resource
@param (object) $input

@return int
Merges the given file s content to the new fields .