loop through and process the $fields into $objects for model methods below
437720
private function models() {
		$relationships = $dates = [];
		$tables = config('center.tables');

		//loop through once to create relationships between tables
		foreach ($tables as $table) {

			$dates[$table->name] = [];

			if (!isset($relationships[$table->name])) $relationships[$table->name] = [];
			
			foreach ($table->fields as $field) {
				
				//define relationships
				if ($field->type == 'checkboxes') {
	
					//out from this object
					$order_by = [];
					foreach ($tables[$field->source]->order_by as $column=>$direction) {
						$order_by[] = '->orderBy("' . $column . '", "' . $direction . '")';
					}
					$relationships[$table->name][] = '
					public function ' . $tables[$field->source]->name . '() {
						return $this->belongsToMany("LeftRight\Center\Models\\' . $tables[$field->source]->model . '", "' . $field->name . '", "' . RowController::formatKeyColumn($table->name) . '", "' . RowController::formatKeyColumn($tables[$field->source]->name) . '")' . implode($order_by) . ';
					}
					';
				
					//back from the related object
					$order_by = [];
					foreach ($table->order_by as $column=>$direction) {
						$order_by[] = '->orderBy("' . $column . '", "' . $direction . '")';
					}
					$relationships[$tables[$field->source]->name][] = '
					public function ' . $table->name . '() {
						return $this->belongsToMany("LeftRight\Center\Models\\' . $table->model . '", "' . $field->name . '", "' . RowController::formatKeyColumn($tables[$field->source]->name) . '", "' . RowController::formatKeyColumn($table->name) . '")' . implode($order_by) . ';
					}
					';	

				} elseif (in_array($field->type, ['date', 'datetime'])) {

					$dates[$table->name][] = '\'' . $field->name . '\'';
				
				} elseif ($field->type == 'image') {

					//cannot overwrite property
					$relationships[$table->name][] = '
					public function ' . substr($field->name, 0, -3) . '() {
						return $this->hasOne("LeftRight\Center\Models\File", "id", "' . $field->name . '");
					}
					';
				
				} elseif (in_array($field->type, ['select', 'user'])) {
					
					//public function ' . $tables[$field->source]->name . '() {

					//out from this object
					$relationships[$table->name][] = '
					public function ' . substr($field->name, 0, -3) . '() {
						return $this->belongsTo("LeftRight\Center\Models\\' . $tables[$field->source]->model . '", "' . $field->name . '");
					}
					';
	
					//back from the related object
					$relationships[$tables[$field->source]->name][] = '
					public function ' . $table->name . '() {
						return $this->hasMany("LeftRight\Center\Models\\' . $table->model . '", "' . $field->name . '");
					}
					';
				}
			}
		}
		
		//debug
		//dd($relationships);

		//now we must loop through again; the first loop set relationships on other tables
		foreach ($tables as $table) {
			eval('namespace LeftRight\Center\Models;
			use Illuminate\Database\Eloquent\SoftDeletes;
			use Auth;
			use DateTime;
			use DB;
			use Eloquent;

			class ' . $table->model . ' extends Eloquent {
			    ' . (isset($table->fields->deleted_at) ? 'use SoftDeletes;' : '') . '
				public $table      = \'' . $table->name . '\'; //public intentionally
				public $timestamps = false; //going to override if present
				protected $guarded = [];
				protected $dates   = [' . implode(',', $dates[$table->name]) . '];

				public static function boot() {
					parent::boot();
			        static::creating(function($object) {' . 
				        (isset($table->fields->precedence) ? '
						$object->precedence = DB::table(\'' . $table->name . '\')->max(\'precedence\') + 1;
						' : '') .
				        (isset($table->fields->created_by) ? '
						$object->created_by = Auth::id();
						' : '') .
				        ($table->timestamps && isset($table->fields->created_at) ? '
						$object->created_at = new DateTime();
						' : '') .
				        (isset($table->fields->updated_by) ? '
						$object->updated_by = Auth::id();
						' : '') .
				        ($table->timestamps && isset($table->fields->updated_at) ? '
						$object->updated_at = new DateTime();
						' : '') . 
					'});
			        static::updating(function($object) {' . 
			        	(isset($table->fields->updated_by) ? '
						$object->updated_by = Auth::id();
						' : '') .
				        ($table->timestamps && isset($table->fields->updated_at) ? '
						$object->updated_at = new DateTime();
						' : '') . 
			        '});
				}

				public function creator() {
					return $this->belongsTo(\'User\', \'created_by\');
				}

				public function updater() {
					return $this->belongsTo(\'User\', \'updated_by\');
				}

				' . implode(' ', $relationships[$table->name]) . '
			}');
			
		}

	}
222253
private function process($post_fields)
    {
        $string = $this->build_query_string($post_fields);
        $result = $this->curl($string);
        $parsed = $this->parse_result($result);

        return $parsed;
    }
1160070
function parseField(field, fieldName, model) {
		// parse & check attributes and include
		parseIncludes(field, fieldName, model.name, model);

		// parse & check order
		parseOrders(field, fieldName, model);
	}
1167061
protected function processField($method, array $field = array(), array $options = array())
    {
        $this->field  = $field;
        $this->method = strtolower($method);

        $this->editFieldhandlerMethod();

        foreach (array('name', 'value', 'type') as $key) {
            $this->editFieldhandlerAttribute($key);
        }

        $fieldhandler_results = $this->executeConstraint($options);

        $this->processConstraintResults($fieldhandler_results);

        return $this->field_value;
    }
846033
def get_nested_fields(schema, model_field=False):
    

    nested_fields = []
    for (key, value) in schema._declared_fields.items():
        if isinstance(value, List) and isinstance(value.container, Nested):
            nested_fields.append(key)
        elif isinstance(value, Nested):
            nested_fields.append(key)

    if model_field is True:
        nested_fields = [get_model_field(schema, key) for key in nested_fields]

    return nested_fields
106033
protected function processField($field)
    {
        $javaScriptCode = [];
        $fieldName = $field->getName();

        foreach ($field->getValidation() as $validationName => $validationConfiguration) {
            $validatorClassName = $validationConfiguration->getClassName();

            if (in_array(AbstractValidator::class, class_parents($validatorClassName))) {
                $javaScriptCode[] = (string)$this->getInlineJavaScriptValidationCode($field, $validationName, $validationConfiguration);
            }
        }

        $javaScriptCode = implode(CRLF, $javaScriptCode);
        $javaScriptFieldName = GeneralUtility::quoteJSvalue($fieldName);

        return <<<JS
            /***************************
            * Field: "$fieldName"
            ****************************/
            field = form.getFieldByName($javaScriptFieldName);

            if (null !== field) {
$javaScriptCode
            }

JS;
    }
768614
function fieldsToMongo(fields) {
    if (!fields) return null
    var hash = {}
    fields.split(',').forEach(function(field) {
        hash[field.trim()] = 1
    })
    return hash
}
988120
private void processProps() {
    ElementFilter
        .fieldsIn(component.getEnclosedElements())
        .stream()
        .filter(field -> hasAnnotation(field, Prop.class))
        .forEach(field -> {
          String propName = field.getSimpleName().toString();
          Prop prop = field.getAnnotation(Prop.class);

          collectionFieldsValidator.validateComponentPropField(field);

          fieldsWithNameExposed.add(new ExposedField(propName, field.asType()));

          optionsBuilder.addStatement(
              "options.addJavaProp($S, $T.getFieldName(this, () -> this.$L = $L), $L, $S)",
              propName,
              VueGWTTools.class,
              propName,
              getFieldMarkingValueForType(field.asType()),
              prop.required(),
              prop.checkType() ? getNativeNameForJavaType(field.asType()) : null
          );
        });
  }
259289
function parseIncludes(field, fieldName, modelName, parent) {
		// check all attributes are strings and valid fields
		if (!field.attributes) {
			field.attributes = [];
		} else {
			if (!Array.isArray(field.attributes)) field.attributes = [field.attributes];

			_.forEach(field.attributes, function(attribute) {
				if (!_.isString(attribute)) throw new Sequelize.VirtualFieldsError("Attribute of virtual field '" + modelName + "'.'" + fieldName + "' is not a string");

				if (!parent.attributes[attribute]) throw new Sequelize.VirtualFieldsError("Attribute of virtual field '" + modelName + "'.'" + fieldName + "' refers to a nonexistent field '" + parent.name + "'.'" + attribute + "'");
			});
		}

		// format includes as {model: model, as: as} and convert strings to models
		if (field.include) {
			if (!Array.isArray(field.include)) field.include = [field.include];

			_.forEach(field.include, function(include, index) {
				include = parseClause(field.include, index, 'Include', modelName, fieldName, parent);

				parseIncludes(include, fieldName, modelName, include.model);
			});
		}
	}
154264
function buildFields (model, fields) {
    //  build list of fields from columns and properties properties
    if (!fields) {
        fields = _.keys(model.extraColumns)
        // if model has schema and properties
        if (model.schemaData) {
            fields = _.uniq( fields.concat( _.keys(model.schemaData.properties) ) )
        }
        // add create time field
        fields.push(metaFields.createTime)
        // add actions field
        fields.push(metaFields.actions)
    }
    // process fields
    fields = _.map(fields, field => {
        // if field is a string the build object
        if (typeof field === 'string') {
            // if field is a meta column then add spec
            if (metaFields[field]) {
                return metaFields[field]
            }
            // create spec
            else {
                field = {
                    property: field,
                }
            }
        }
        // create default label if label not set
        if (!field.title) {
            // use property name converted to upper case first words
            field.title = changeCase.titleCase(field.property)
        }
        // get column for property (if any)
        var column = model.columns[field.property]
        // if field is column then set properties based on column
        if (column) {
            // if column has index allow filter and search on column
            if (column.index || column.unique) {
                field.orderAscIcon = 'sort-alpha-asc'
                field.orderAscUrl = './?orderColumn='+field.property+'&orderDirection=ASC'
                field.orderDescIcon = 'sort-alpha-desc'
                field.orderDescUrl = './?orderColumn='+field.property+'&orderDirection=DESC'
                field.searchBy = true
                field.searchIcon =  'search'
            }
        }
        // return field spec
        return field
    })
    // return formatted fields
    return fields
}
1166414
function (cb) {

                // loop through each record
                async.each(Object.keys(records), function (index, recordDone) {

                    // store the rendered content into a separate property
                    records[index]['rendered'] = {};

                    // loop through each field
                    async.each(Object.keys(req.linz.model.list.fields), function (field, fieldDone) {

                        // Skip this field if we have a falsy value
                        if (!req.linz.model.list.fields[field]) {
                            return fieldDone();
                        }

                        // If we have a reference field, data has been pre-rendered.
                        // Let's grab it from there.
                        if (req.linz.model.schema.tree[field] && req.linz.model.schema.tree[field].ref) {

                            // The default value, but could be replaced below if the conditions are right.
                            records[index]['rendered'][field] = records[index][field];


                            // Do we have a rendered result for this field in this particular record?
                            // Support multiple types ref fields.
                            if (refColData[field].rendered && records[index][field] && refColData[field].rendered[linz.api.model.getObjectIdFromRefField(records[index][field]).toString()]) {

                                records[index]['rendered'][field] = refColData[field].rendered[linz.api.model.getObjectIdFromRefField(records[index][field]).toString()];

                            }

                            // We're all done here.
                            return fieldDone();

                        }

                        // This will only execute if we don't have a ref field.

                        let args = [];

                        // value is not applicable for virtual field
                        if (!req.linz.model.list.fields[field].virtual) {
                            args.push(records[index][field]);
                        }

                        args.push(mongooseRecords[index]);
                        args.push(field);
                        args.push(req.linz.model);
                        args.push(function (err, value) {

                            if (!err) {
                                records[index]['rendered'][field] = value;
                            }

                            return fieldDone(err);

                        });

                        // call the cell renderer and update the content with the result
                        // val, record, fieldname, model, callback
                        req.linz.model.list.fields[field].renderer.apply(this, args);

                    }, function (err) {

                        recordDone(err);

                    });


                }, function (err) {

                    cb(err);

                });

            }
974383
def process_models(attrs, base_model_class):
        
        attrs.update(base_model_class._DEFAULT_BASE_FIELDS)
        attrs['_instance_registry'] = set()
        attrs['_is_unpermitted_fields_set'] = False
        attrs['save_meta_data'] = None
        attrs['_pre_save_hook_called'] = False
        attrs['_post_save_hook_called'] = False
        DEFAULT_META = {'bucket_type': settings.DEFAULT_BUCKET_TYPE,
                        'field_permissions': {},
                        'app': 'main',
                        'list_fields': [],
                        'list_filters': [],
                        'search_fields': [],
                        'fake_model': False,
                        }
        if 'Meta' not in attrs:
            attrs['Meta'] = type('Meta', (object,), DEFAULT_META)
        else:
            for k, v in DEFAULT_META.items():
                if k not in attrs['Meta'].__dict__:
                    setattr(attrs['Meta'], k, v)
37392
function loadFields(list, callback) {
  list.forEach(loadMethods)

  function loadMethods(field) {
    var module = require('./fields/' + field + '.js')
      , methods

    if (typeof module === 'function' || typeof module === 'string') {
      methods = {}
      methods[field] = module
    }
    else {
      methods = module
    }

    callback(methods)
  }
}
94430
protected function processModuleFields()
    {
        $overrideCasts = array_get($this->overrides, 'attributes.casts', []);
        $removeCasts   = array_get($this->overrides, 'attributes.casts-remove', []);


        foreach ($this->module['fields'] as $fieldId => $fieldData) {

            $attributeName = $this->normalizeDb($fieldData['name']);
            $relationName  = camel_case($attributeName);

            switch ($fieldData['field_type_id']) {

                // references

                case FieldType::TYPE_REFERENCE:
                case FieldType::TYPE_REFERENCE_CROSS:
                case FieldType::TYPE_REFERENCE_NEGATIVE:

                    // add foreign key if it is different than the targeted model name
                    // (would break the convention) -- this is NOT necessary, since the convention
                    // for the CmsModel class is to use the relation name anyway!
                    //
                    // this only needs to be set if the relation name ends up being different
                    // from the relation name
                    //
                    // todo: so keep a close eye on the reversed relationships!
                    $keyName = null;
                    //if ($relationName !== studly_case($this->data->rawData['modules'][ $fieldData['refers_to_module'] ]['name'])) {
                    //    $keyName = $attributeName;
                    //}

                    // attribute names with numbers in them wreak havoc on the name conversion methods
                    // so always add the key for those
                    if (preg_match('#\d#', $relationName)) {
                        $keyName = $attributeName;
                    }

                    // in some weird cases, cmses have been destroyed by leaving in relationships
                    // that do not refer to any model; these should be skipped
                    if (empty($fieldData['refers_to_module'])) {
                        $this->context->log(
                            "Relation '{$relationName}', field #{$fieldId} does not refer to any module, skipped.",
                            Generator::LOG_LEVEL_ERROR
                        );
                        break;
                    }

                    $this->model['relationships']['normal'][ $relationName ] = [
                        'type'     => Generator::RELATIONSHIP_BELONGS_TO,    // reverse of hasOne
                        'model'    => $fieldData['refers_to_module'],
                        'single'   => ($fieldData['value_count'] == 1),
                        'count'    => $fieldData['value_count'],  // should always be 1 for single ref
                        'field'    => $fieldId,
                        'key'      => $keyName,
                        'negative' => ($fieldData['field_type_id'] == FieldType::TYPE_REFERENCE_NEGATIVE),
                        'special'  => CmsModel::RELATION_TYPE_MODEL,
                    ];

                    if (config('pxlcms.generator.models.hide_foreign_key_attributes')) {
                        $this->model['hidden'][] = $attributeName;
                    }
                    break;

                case FieldType::TYPE_REFERENCE_MANY:
                case FieldType::TYPE_REFERENCE_AUTOSORT:
                case FieldType::TYPE_REFERENCE_CHECKBOXES:

                    if (empty($fieldData['refers_to_module'])) {
                        $this->context->log(
                            "Relation '{$relationName}', field #{$fieldId} does not refer to any module, skipped.",
                            Generator::LOG_LEVEL_ERROR
                        );
                        break;
                    }

                    $this->model['relationships']['normal'][ $relationName ] = [
                        'type'     => Generator::RELATIONSHIP_BELONGS_TO_MANY,
                        'model'    => $fieldData['refers_to_module'],
                        'single'   => false,
                        'count'    => $fieldData['value_count'],    // 0 for no limit
                        'field'    => $fieldId,
                        'negative' => false,
                        'special'  => CmsModel::RELATION_TYPE_MODEL,
                    ];
                    break;


                // special references

                case FieldType::TYPE_IMAGE:
                case FieldType::TYPE_IMAGE_MULTI:
                    $this->model['relationships']['image'][ $relationName ] = [
                        'type'       => ($fieldData['value_count'] == 1)
                                            ? Generator::RELATIONSHIP_HAS_ONE
                                            : Generator::RELATIONSHIP_HAS_MANY,
                        'single'     => ($fieldData['value_count'] == 1),
                        'count'      => $fieldData['value_count'],
                        'field'      => $fieldId,
                        'translated' => (bool) $fieldData['multilingual'],
                        'resizes'    => $this->getImageResizesForField($fieldId),
                        'special'    => CmsModel::RELATION_TYPE_IMAGE,
                    ];
                    break;

                case FieldType::TYPE_FILE:
                    $this->model['relationships']['file'][ $relationName ] = [
                        'type'       => ($fieldData['value_count'] == 1)
                                            ? Generator::RELATIONSHIP_HAS_ONE
                                            : Generator::RELATIONSHIP_HAS_MANY,
                        'single'     => ($fieldData['value_count'] == 1),
                        'count'      => $fieldData['value_count'],
                        'field'      => $fieldId,
                        'translated' => (bool) $fieldData['multilingual'],
                        'special'    => CmsModel::RELATION_TYPE_FILE,
                    ];
                    break;

                case FieldType::TYPE_CHECKBOX:
                    $this->model['relationships']['checkbox'][ $relationName ] = [
                        'type'    => Generator::RELATIONSHIP_HAS_MANY,
                        'single'  => false,
                        'count'   => $fieldData['value_count'],
                        'field'   => $fieldId,
                        'special' => CmsModel::RELATION_TYPE_CHECKBOX,
                    ];
                    break;


                // normal fields

                case FieldType::TYPE_INPUT:
                case FieldType::TYPE_DROPDOWN:
                case FieldType::TYPE_LABEL:
                case FieldType::TYPE_COLORCODE:
                case FieldType::TYPE_TEXT:
                case FieldType::TYPE_TEXT_HTML_FLEX:
                case FieldType::TYPE_TEXT_HTML_RAW:
                case FieldType::TYPE_TEXT_HTML_FCK:
                case FieldType::TYPE_TEXT_HTML_ALOHA:
                case FieldType::TYPE_TEXT_LONG:
                case FieldType::TYPE_BOOLEAN:
                case FieldType::TYPE_INTEGER:
                case FieldType::TYPE_NUMERIC:
                case FieldType::TYPE_FLOAT:
                case FieldType::TYPE_DATE:
                case FieldType::TYPE_CUSTOM_HIDDEN:
                case FieldType::TYPE_CUSTOM:
                case FieldType::TYPE_SLIDER:
                case FieldType::TYPE_LOCATION:

                    switch ($fieldData['field_type_id']) {

                        case FieldType::TYPE_BOOLEAN:
                            $this->model['casts'][ $attributeName ] = 'boolean';
                            break;

                        case FieldType::TYPE_INTEGER:
                        case FieldType::TYPE_SLIDER:
                            $this->model['casts'][ $attributeName ] = 'integer';
                            break;

                        case FieldType::TYPE_NUMERIC:
                        case FieldType::TYPE_FLOAT:
                            $this->model['casts'][ $attributeName ] = 'float';
                            break;

                        case FieldType::TYPE_DATE:
                            if ( ! array_key_exists($attributeName, $overrideCasts)) {
                                $this->model['dates'][] = $attributeName;
                            }
                            break;

                        case FieldType::TYPE_LOCATION:
                            $this->model['casts'][ $attributeName ] = 'array';
                            break;

                        // default omitted on purpose
                    }

                    if ($fieldData['multilingual']) {
                        $this->model['is_translated']           = true;
                        $this->model['translated_attributes'][] = $attributeName;
                        $this->model['translated_fillable'][]   = $attributeName;
                    } else {
                        $this->model['normal_attributes'][] = $attributeName;
                        $this->model['normal_fillable'][]   = $attributeName;
                    }

                    // if a default is set, store it
                    if (    $fieldData['default'] !== null
                        &&  $fieldData['default'] !== ''
                    ) {

                        $default = "'" . $fieldData['default'] . "'";

                        if (array_key_exists($attributeName, $this->model['casts'])) {

                            switch ($this->model['casts'][ $attributeName ]) {

                                case 'boolean':
                                    $default = ($fieldData['default'] == '1' || $fieldData['default'] == 'true') ? 'true' : 'false';
                                    break;

                                case 'integer':
                                case 'float':
                                    $default = $fieldData['default'];
                                    break;

                                // default omitted on purpose
                            }
                        }

                        $this->model['defaults'][ $attributeName ] = $default;
                    }

                    break;

                case FieldType::TYPE_RANGE:
                default:
                    throw new Exception(
                        "Unknown/unhandled field type {$fieldData['field_type_id']} "
                        . "({$fieldData['field_type_name']})"
                    );
            }
        }

        // force hidden override
        if (count($this->model['hidden']) && ! count($this->overrideHidden)) {

            $this->model['hidden'] = array_merge(
                $this->model['hidden'],
                config('pxlcms.generator.models.default_hidden_fields', [])
            );
        }


        // clear, set or remove fillable attributes by override
        if (array_get($this->overrides, 'attributes.fillable-empty')) {

            $this->model['normal_fillable']     = [];
            $this->model['translated_fillable'] = [];

        } elseif ($overrideFillable = array_get($this->overrides, 'attributes.fillable', [])) {

            $this->model['normal_fillable']     = $overrideFillable;
            $this->model['translated_fillable'] = [];

        } elseif ($removeFillable = array_get($this->overrides, 'attributes.fillable-remove', [])) {

            $this->model['normal_fillable']     = array_diff($this->model['normal_fillable'], $removeFillable);
            $this->model['translated_fillable'] = array_diff($this->model['translated_fillable'], $removeFillable);
        }


        // force casts as overridden
        foreach ($overrideCasts as $attributeName => $type) {
            if (array_key_exists($attributeName, $this->model['casts'])) {
                $this->model['casts'][ $attributeName ] = $type;
            }
        }

        foreach ($removeCasts as $attributeName) {
            if (array_key_exists($attributeName, $this->model['casts'])) {
                unset ($this->model['casts'][ $attributeName ]);
            }
        }

        // enable timestamps?
        if (    config('pxlcms.generator.models.enable_timestamps_on_models_with_suitable_attributes')
            &&  in_array('created_at', $this->model['dates'])
            &&  in_array('updated_at', $this->model['dates'])
        ) {
            $this->model['timestamps'] = true;
        }
    }
855577
function updateFieldsRec(toData, fromData) {
        var keys = Object.keys(fromData),
            i;

        for (i = 0; i < keys.length; i += 1) {
            if (isTrueObject(fromData[keys[i]]) && isTrueObject(toData[keys[i]])) {
                updateFieldsRec(toData[keys[i]], fromData[keys[i]]);
            } else {
                toData[keys[i]] = fromData[keys[i]];
            }
        }
    }
1105520
function transformModel (options, data) {
  const prop = (options.model && options.model.prop) || 'value';
  const event = (options.model && options.model.event) || 'input'
  ;(data.attrs || (data.attrs = {}))[prop] = data.model.value;
  const on = data.on || (data.on = {});
  const existing = on[event];
  const callback = data.model.callback;
  if (isDef(existing)) {
    if (
      Array.isArray(existing)
        ? existing.indexOf(callback) === -1
        : existing !== callback
    ) {
      on[event] = [callback].concat(existing);
    }
  } else {
    on[event] = callback;
  }
}
373989
function(fields, data) {
    if (!_.isString(fields)) {
      return data;
    }

    // If a field is specified as `foo.bar` or `foo.bar.baz`,
    // Convert it to just `foo`
    var map = {};
    _.forEach(fields.split(','), function(field) {
      map[field.split('.')[0]] = 1;
    });

    var keys = _.keys(map);
    if (_.isArray(data)) {
      data = _.map(data, function(object) {
        return _.pick(object, keys);
      });
    } else if (_.isObject(data)) {
      data = _.pick(data, keys);
    }

    return data;
  }