Fill a model from input or an array

@return bool
168560
private function fillModel()
    {
        // If we've already filled this model don't fill it again
        if ($this->hydrated) return true;

        // Fire hydrating event
        if ($this->fireModelEvent('hydrating') === false) return false;

        // Fill from data and record we've filled it
        $this->fill($this->dataset);
        $this->hydrated = true;

        // Remove any fields from the model which can't be submitted, such as objects and arrays
        // - This will prevent errors with bound objects being saved twice
        $this->removeInvalidAttributes();

        $this->fireModelEvent('hydrated', false);

        return true;
    }
1077962
public function fill(Identifiable $model, array $attributes)
    {

        $model = $this->checkTypeAndReturn($model);
        $changed = false;

        foreach ($attributes as $key=>$value) {
            // Check for exact comparison
            if(isset($model[$key]) && $model[$key] === $value) {
                continue;
            }
            $model[$key] = $value;
            $changed = true;
        }
        return $changed;
    }
1266654
protected function fromSentinel()
    {
        $user = $this->laravel['sentinel']->check();

        return empty($user) === true ? [] : [
            'id' => null,
            'rows' => $user->toArray(),
        ];
    }
1161453
public function toArray()
    {
        $attr = !empty($this->getWarden()) ? $this->getWarden() : null;
        if (empty($attr)) {
            $attr = empty($this->getVisible()) ? $this->getFillable() : $this->getVisible();
        }
        $returnable = [];

        $f_model = \FormModel::using('plain')->withModel($this);
        foreach ($attr as $old => $new) {
            if (!empty($relations = $f_model->getRelationalDataAndModels($this, $old))) {
                $returnable[$new] = $relations;
            }
            if (stripos($old, '_id') !== false) {
                if (!empty($this->$new)) {
                    $returnable[$new] = $relations;
                }
            } else {
                if (isset($this->$old)) {
                    $returnable[$new] = $this->$old;
                }
            }
        }

        return $returnable;
    }
115182
public function fillModel(&$model, $input)
    {
        $time       = false;
        $field_name = $this->getOption('field_name');

        if (empty($input) && $field_name) {
            $model->{$field_name} = null;

            return;
        } elseif (!empty($input) && $input !== '0000-00-00') {
            $time = new DateTime($input);
        }

        //first we validate that it's a date/time
        if ($time !== false) {
            //fill the model with the correct date/time format
            $model->{$field_name} = $this->getDateString($time);
        }
    }
238518
public function fillModel(&$model, $input)
    {
        $model->{$this->getOption('foreign_key')} = $input !== 'false' ? $input : null;

        $model->__unset($this->getOption('field_name'));
    }
1029384
protected function prepareInput()
    {
        $arguments = [
            '--optimize' => (bool) $this->file->get(self::SETTING_OPTIMIZE),
            '--no-dev'   => true,
        ];

        $input = new ArrayInput($arguments);
        $input->setInteractive(false);

        return $input;
    }
54834
protected function fillIfNotFilled()
    {
        if (!$this->lazyLoad || $this->lazyLoaded || !$this->repository) {
            return;
        }

        $this->repository->fill($this, $this->lazyLoadAttributes);

        $this->lazyLoaded = true;
    }
1264637
public function loadModel()
    {
        $modelClassName = $this->namespace . 'Models\Base';

        if (class_exists($modelClassName)) {
            models()->load($modelClassName, strtolower($this->type));
        }
    }
1273519
private function filterModel(Input $input)
    {
        $models = array_filter(
            $this->findAllModels(),
            function (CommandInterface $command) use ($input) {
                return preg_match(preg_quote($command->getCmd()), $input->text);
            }
        );

        if (empty($models)) {
            return null;
        }

        return $models[0];
    }
344349
public function input()
    {
        return array_replace_recursive($this->query->all(), $this->attributes->all(), $this->request->all());
    }
357620
protected function fillModelClassIndex()
    {
        $this->modelClassIndex = [];

        foreach ($this->information as $index => $information) {
            $this->modelClassIndex[ $information->modelClass() ] = $index;
        }

        return $this;
    }
665834
public function process($model, $input)
    {
        $column = $this->getColumn();

        if(isset($input[$column])) {
            $model->{$column} = $input[$column];
        }

        return $model;
    }
1278237
public function inputs()
    {
        $aReturn = [];
        foreach ($this->getFieldDefinitions() as $strFieldName => $aField) {
            $skeFormInput = new SkeFormInput(
                $strFieldName,
                $aField['type'] ?? 'text',
                $aField['options'] ?? [],
                $aField['attribs'] ?? []
            );
            // Set value for existing event
            if ($this->skeVent) {
                $skeFormInput->setValue($this->skeVent->getProperty($strFieldName));
                if ($this->skeVent->hasError($strFieldName))
                    $skeFormInput->setError($this->skeVent->getError($strFieldName));
            }
            $aReturn[] = $skeFormInput;
        }
        return $aReturn;
    }
523750
public function fill()
    {
        $totalColumn = $this->db->getTotalColumns();
        $rows = array();
        for ($n = 0; $n < $this->num; $n++) {
            $fakeRow = new DbRowEntity();
            for ($i = 0; $i < $totalColumn; $i++) {
                if ($this->db->isColumnAutoincrement($i)) {
                    continue;
                }
                $fieldName = $this->db->getColumnName($i);
                $fakeType = $this->db->getColumnType($i);
                $dataLength = $this->db->getColumnLength($i);
                $fakeData = $this->fakeColumn($fieldName, $fakeType, $dataLength);

                $fakeRow->setFields(new DbFieldEntity($fieldName, $fakeData[0], $fakeType, $dataLength));
            }
            $this->db->insert($fakeRow);

            $rows[] = $fakeRow->toArray();
        }

        return $rows;
    }
824666
public function fill(array $attributes = [])
    {
        $this->raw = $attributes;

        $excludes = config("api.excludes");

        foreach ($attributes as $key => $attribute) {
            // Guarded attributes should be removed
            if (in_array($key, $excludes)) {
                unset($attributes[$key]);
            }
            else if (method_exists($this, $key) && ((is_array($attribute) || is_null($attribute)))) {
                // Its a relation
                $this->relationAttributes[$key] = $attribute;

                // For belongs to relation, while filling, we need to set relation key.
                $relation = call_user_func([$this, $key]);

                if ($relation instanceof BelongsTo) {
                    $primaryKey = $relation->getRelated()->getKeyName();

                    if ($attribute !== null) {
                        // If key value is not set in request, we create new object
                        if (!isset($attribute[$primaryKey])) {
                            throw new RelatedResourceNotFoundException('Resource for relation "' . $key . '" not found');
                        }
                        else {
                            $model = $relation->getRelated()->find($attribute[$primaryKey]);

                            if (!$model) {
                                // Resource not found
                                throw new ResourceNotFoundException();
                            }
                        }
                    }

                    $relationKey = $relation->getForeignKey();

                    $this->setAttribute($relationKey, ($attribute === null) ? null : $model->getKey());
                }

                unset($attributes[$key]);
            }
        }

        return parent::fill($attributes);
    }
1305332
public function fill($model, $row)
    {
        if ($this->constant == false) {
            if (isset($this->defaultValue) && $this->defaultValue != null) {
                $model->{$this->nameInModel} = $this->defaultValue;
            }
            foreach ($this->nameInFile as $subkey) {
                if (isset($row[$subkey])) {
                    $model->{$this->nameInModel} = $this->parse($row[$subkey], $row);
                    return true;
                }
            }
        } else {
            $model->{$this->nameInModel} = $this->constant;
            return true;
        }
        return false;
    }