Returns the value of fields provided from the model instance.

@author: Eddilbert Macharia (http://eddmash.com)<edd.cowan@gmail.com>

@param Model $modelInstance
@param array $fields

@return array
171822
public function getInstanceValueForFields(Model $modelInstance, $fields)
    {
        $values = [];
        /** @var $field Field */
        foreach ($fields as $field) {
            $val = $modelInstance->{$field->getAttrName()};
            if (!$val) {
                continue;
            }
            $values[] = $val;
        }

        return $values;
    }
1256038
public static function mapGraphNodeFieldNamesToDatabaseColumnNames(Model $object, array $fields)
    {
        foreach ($fields as $field => $value) {
            if (static::graphNodeFieldIsWhiteListed(static::fieldToColumnName($field))) {
                $object->{static::fieldToColumnName($field)} = $value;
            }
        }
    }
1277202
public function get($model, $field, $row)
    {
        $value = $model->getFieldValue($field);
        return $this->parse($value, $row);
    }
86958
protected function getPropertyArrayValue($value, $modelFieldInfo, $forOutput = FALSE) {
    if (!is_object($value)) {
      return $value;
    }
    else {
      if ($modelFieldInfo->isMABIModel) {
        /**
         * @var $subModel \MABI\Model
         */
        $subModel = $value;
        return $subModel->getPropertyArray($forOutput);
      }
      elseif ($modelFieldInfo->type == 'DateTime' || $modelFieldInfo->type == '\DateTime') {
        /**
         * @var $date \DateTime
         */
        $date = $value;
        return $date->getTimestamp();
      }
    }

    return NULL;
  }
1137581
public function getField($objectName, $fieldName, $excludeFormDefaults = true)
    {
        $modelConfiguration = $this->getModelConfiguration($objectName);
        if (isset($modelConfiguration['__field_index'][$fieldName])) {
            $fieldConfiguration = array_replace_recursive($this->defaultFieldConfiguration, $modelConfiguration['fields'][$modelConfiguration['__field_index'][$fieldName]]);
            if ($excludeFormDefaults && isset($fieldConfiguration['form_defaults'])) {
                unset($fieldConfiguration["form_defaults"]);
            }

            return $fieldConfiguration;
        }
    }
852679
protected function getFieldsFromModels($models)
    {
        if (!$models->first()) {
            // No models, we can't add any columns.
            return [];
        }

        $model = $models->first();

        // These are the Laravel basic timestamp fields which we don't want to display, by default
        $timestamp_fields = ['created_at', 'updated_at', 'deleted_at'];
        // Grab the basic fields from the first model
        $fields = array_keys($model->toArray());
        // Remove the timestamp fields
        $fields = array_diff($fields, $timestamp_fields);
        if ($model->isSortable) {
            // Add the fields from the model's sortable array
            $fields = array_unique(array_merge($fields, $model->getSortable()));
        }

        return $fields;
    }
1254891
def get_fields(model, fields, meta=None):
    
    model = get_model(model)
    if fields is not None:
        f = fields
    elif meta and hasattr(model, meta):
        m = getattr(model, meta)
        if hasattr(m, 'fields'):
            f = m.fields
        else:
            f = model._fields_list
    else:
        f = model._fields_list
        
    fields_list = []
    for x in f:
        field = {}
        if isinstance(x, str):  #so x is field_name
            field['name'] = x
        elif isinstance(x, tuple):
            field['name'] = x[0]
            field['field'] = x[1]
        elif isinstance(x, dict):
            field = x.copy()
        else:
            raise UliwebError('Field definition {!r} is not right, it should be just like (field_name, form_field_obj)'.format(x))
        
        if 'prop' not in field:
            if hasattr(model, field['name']):
                field['prop'] = getattr(model, field['name'])
            else:
                field['prop'] = None
        
        fields_list.append((field['name'], field))
    return fields_list
945483
public static function hasRequiredFields($model, $fields)
    {
        foreach ($fields as $column) {
            if (!is_array($column)) {
                if ($column instanceof ActiveField && $model->isAttributeRequired($column->attribute)) {
                    return true;
                }
                continue;
            }

            foreach ($column as $row) {
                if (!is_array($row)) {
                    if ($row instanceof ActiveField && $model->isAttributeRequired($row->attribute)) {
                        return true;
                    }
                    continue;
                }

                if (static::hasRequiredFields($model, $row)) {
                    return true;
                }
            }

        }
        return false;
    }
359676
public function getModelArray(Model $model)
    {
        $result = [];
        foreach ($model->getAttributes() as $key => $value) {
            $result[] = ['type' => 'text', 'name' => $key, 'key' => $key.' :', 'value' => $value];
        }
        unset($result[0]);

        return $result;
    }
472325
private function getFieldsConfiguration($model, $fields = [])
    {
        $configuration = $properties = [];
        $ro = new \ReflectionObject($model);
        if (empty($fields)) {
            $properties = $ro->getProperties();
        } else {
            foreach (array_keys($fields) as $field) {
                // setting the configuration to null guarantees the order of elements in there
                // to match the order specified in $fields
                $configuration[$field] = null;
                if (! $ro->hasProperty($field)) {
                    continue; // most prob a class-level field, order will be maintained due to trick above
                }
                $properties[] = $ro->getProperty($field);
            }
        }
        $fieldConfigurations = [];
        // first are coming properties
        foreach ($properties as $property) {
            $propertyName = $property->getName();
            $propertyIsListed = array_key_exists($propertyName, $fields);
            if (!empty($fields) && !$propertyIsListed) {
                continue; // list of fields was specified and current one is not there
            }
            $fieldConfiguration = $this->annotationReader->getPropertyAnnotation($property, Field::class);
            if ($fieldConfiguration === null && !$propertyIsListed) {
                continue;
            }
            $fieldConfigurations[$propertyName] = $fieldConfiguration;
        }
        // later are coming class-level fields. We need to iterate through all annotations as there's no method
        // to get *all* occurrences of chosen annotation.
        foreach ($this->annotationReader->getClassAnnotations($ro) as $annotation) {
            if (! $annotation instanceof Field) {
                continue;
            }
            $propertyName = $annotation->value;
            if (!empty($fields) && !array_key_exists($propertyName, $fields)) {
                continue; // list of fields was specified and current one is not there
            }
            $fieldConfigurations[$propertyName] = $annotation;
        }
        foreach ($fieldConfigurations as $propertyName => $fieldConfiguration) {
            $configuration[$propertyName] = (array)$fieldConfiguration;
            if (isset($fields[$propertyName])) {
                $configuration[$propertyName] = array_replace_recursive($configuration[$propertyName], $fields[$propertyName]);
            }
            if ($configuration[$propertyName]['type'] === EmbedType::class) {
                if (! $ro->hasProperty($propertyName) || ($value = $ro->getProperty($propertyName)->getValue($model)) === null) {
                    $value = $this->instantiator->instantiate($configuration[$propertyName]['class']);
                }
                $configuration[$propertyName]['data_class'] = $configuration[$propertyName]['class'];
                $configuration[$propertyName]['model'] = $value;
            }
            // this variable comes from Doctrine\Common\Annotations\Annotation
            unset($configuration[$propertyName]['value']);
        }
        return $configuration;
    }
657893
protected function getPrimaryField(array $fields)
    {
        foreach ($fields as $field) {
            if ($this->isField($field) && ($field->isPrimary || $field->isAutoIncrement)) {
                return $field;
            }
        }

        return null;
    }
932607
public function getFieldName($field, $modelName)
    {
        if (isset($this->_unionMapsTo[$modelName][$field])) {
            return $this->_unionMapsTo[$modelName][$field];
        }

        return $field;
    }
959885
def get_fields(model_class):
    
    return [
        attr for attr, value in model_class.__dict__.items()
        if issubclass(type(value), (mongo.base.BaseField, mongo.EmbeddedDocumentField))  # noqa
    ]
239562
public function importFields($model, $fields = null)
    {
        $this->model = $model;
        $this->grid = $this->owner;

        if ($fields === false) {
            return;
        }

        if (!$fields) {
            $fields = 'visible';
        }
        if (!is_array($fields)) {
            // note: $fields parameter only useful if model is SQL_Model
            $fields = $model->getActualFields($fields);
        }

        // import fields one by one
        foreach ($fields as $field) {
            $this->importField($field);
        }
        $model->setActualFields($fields);

        return $this;
    }
1065928
public function export(Model $m, $fields = null)
    {
        $data = $m->action('select', [$fields]);

        return array_map(function ($r) use ($m) {
            return $this->typecastLoadRow($m, $r);
        }, $data->get());
    }
1309437
public function getValueFromFieldDescription($object, FieldDescriptionInterface $fieldDescription)
    {
        $value = null;

        if (!$object) {
            return $value;
        }

        try {
            $value = $fieldDescription->getValue($object);
        } catch (NoValueException $e) {
            if ($fieldDescription->getAssociationAdmin()) {
                $value = $fieldDescription->getAssociationAdmin()->getNewInstance();
            }
        }

        return $value;
    }
886311
protected function getEagerModelKeys(array $models)
    {
        // First we need to gather all of the keys from the parent models so we know what
        // to query for via the eager loading query. We will add them to an array then
        // execute a "where in" statement to gather up all of those related records.
        $keys = collect($models)->map(function ($model) {
            return $model->{$this->foreignKey};
        })->filter()->all();

        // If there are no keys that were not null we will just return an array with either
        // null or 0 in (depending on if incrementing keys are in use) so the query wont
        // fail plus returns zero results, which should be what the developer expects.
        if (count($keys) === 0) {
            return [$this->relationHasIncrementingId() ? 0 : null];
        }

        return array_values(array_unique($keys));
    }