public function setFields($fields = [])
    {
        $existingSchema = $this->get();

        $request = [];
        foreach ($fields as $field) {
            $mode = $this->hasField($field['name'], $existingSchema) ? 'replace-field' : 'add-field';
            $request[$mode][] = $field;
        }

        return $this->request($request);
    }
public function setFields($fields = [])
    {
        $existingSchema = $this->get();

        $request = [];
        foreach ($fields as $field) {
            $mode = $this->hasField($field['name'], $existingSchema) ? 'replace-field' : 'add-field';
            $request[$mode][] = $field;
        }

        return $this->request($request);
    }
public function setFields ( $ fields = [ ] ) { $ existingSchema = $ this -> get ( ) ; $ request = [ ] ; foreach ( $ fields as $ field ) { $ mode = $ this -> hasField ( $ field [ 'name' ] , $ existingSchema ) ? 'replace-field' : 'add-field' ; $ request [ $ mode ] [ ] = $ field ; } return $ this -> request ( $ request ) ; }
Update field definition if field exists, otherwise, add

@param array $fields

@return mixed
Update field definition if field exists otherwise add