Fill the model with attributes $attributes.

@param \Ems\Contracts\Core\Identifiable $model
@param array                            $attributes

@return bool if attributes where changed after filling
548319
public function fill(Identifiable $model, array $attributes)
    {
        $this->publish('filling', $model, $attributes);
        $filtered = $this->toModelAttributes($model, $attributes);
        $model->fill($filtered);
        $this->publish('filled', $model, $attributes);

        return true;
    }
547875
public function addAttributes(array $attributes)
    {
        foreach ($attributes as $key => $value) {
            $this->addAttribute($key, $value);
        }
    }
1018265
protected function addAttributes(&$html, array $attributes)
	{
		if ( count($attributes) > 0 )
		{
			$attributes = Html::arrayToAttributes($attributes);

			$html .= ' ' . $attributes;
		}
	}
559807
public static function makeForModel($model, $attributes)
    {
        if (is_string($attributes)) {
            $attributes = ['name' => $attributes];
        }

        if ($model === '*') {
            return (new static)->forceFill($attributes + [
                'entity_type' => '*',
            ]);
        }

        if (is_string($model)) {
            $model = new $model;
        }

        return (new static)->forceFill($attributes + [
            'entity_type' => $model->getMorphClass(),
            'entity_id'   => $model->exists ? $model->getKey() : null,
        ]);
    }
1178685
public function update(array $attributes = [])
    {
        $this->fill($attributes);

        $modifications = $this->getModifications();

        if (count($modifications) > 0) {
            $this->fireModelEvent(new Events\Updating($this));

            // Push the update.
            if ($this->query->getConnection()->modifyBatch($this->getDn(), $modifications)) {
                // Re-sync attributes.
                $this->syncRaw();

                $this->fireModelEvent(new Events\Updated($this));

                // Re-set the models modifications.
                $this->modifications = [];

                return true;
            }

            // Modification failed, return false.
            return false;
        }

        // We need to return true here because modify batch will
        // return false if no modifications are made
        // but this may not always be the case.
        return true;
    }
808315
private function fill(array $attributes)
    {
        $name = array_filter(explode(' ', $attributes['name']));
        $name = array_shift($name);

        $bindValueName = $name;
        if (substr($name, -1) === '.') {
            $bindValueName = substr($bindValueName, 0, -1);
        }

        $attributes['value'] = $this->getValue($bindValueName, $attributes['value'] ?? null);

        $binding = explode('.', $name);

        $attributes['name'] = '';
        foreach ($binding as $key => $bind) {
            if (! is_null($attributes['prefix'])) {
                $attributes['name'] .= '['.$bind.']';
                continue;
            }

            if ($key === 0) {
                $attributes['name'] .= $bind;
                continue;
            }

            $attributes['name'] .= '['.$bind.']';
        }

        return $attributes;
    }
198778
public function fill(Identifiable $config, array $attributes)
    {
        if (!$attributes) {
            return false;
        }

        foreach ($attributes as $key => $value) {
            if (in_array($key, ['collection', 'assets', 'files'])) {
                $this->addCollection($config, $value, $attributes);
                continue;
            }
            $this->addToConfig($config, $key, $value);
        }

        return true;
    }
1029076
public function store(array $attributes)
    {
        $model = $this->make([]);

        $this->validate($attributes, 'store');

        $this->fill($model, $attributes);

        $this->callBeforeListeners('store', [$model, $attributes]);
        $this->save($model);
        $this->callAfterListeners('store', [$model, $attributes]);

        return $model;
    }
1244940
public function fill(array $attributes) {
        $locales = Locale\get_locales();

        foreach($locales as $locale => $options)
            if( in_array($locale, array_keys($attributes)) )
                $this->translations[$locale] = array_pull($attributes, $locale);

        return parent::fill($attributes);
    }
182554
public function addField(array $attributes)
    {
        $field = $this->fields()->create($attributes);

        $this->save();

        return $field;
    }
943653
private function fill($attributes)
    {
        // json
        if (is_string($attributes)) {
            $attributes = json_decode($attributes, true);
        }

        // check if attributes are valid
        if (!is_array($attributes)) {
            throw new \InvalidArgumentException('Attributes must be of type array or a valid json string');
        }

        foreach ($attributes as $key => $value) {
            $this->setAttribute($key, $value);
        }
    }
701122
public function store(array $attributes)
    {
        $model = $this->make([]);

        $this->validate($attributes, 'store');

        $this->fillModel($model, $attributes);
        $this->fire($this->event('storing'), [$model, $attributes]);
        $model->save();
        $this->fire($this->event('stored'), [$model, $attributes]);
        return $model;
    }
447029
protected function fillAttributes($resource, array $attributes)
    {
        foreach ($attributes as $attribute => $value) {
            $setter = "set" . ucfirst($attribute);

            if (method_exists($resource, $setter)) {
                $resource->$setter($value);
            }
        }
    }
799659
public function update($attributes)
    {
        if (!empty($attributes)) {
            foreach ($attributes as $attribute => $value) {
                $this->set($attribute, $value);
            }
        }

        return $this;
    }
982479
public function dynamic($model, &$attributes = null)
    {
        // dynamic migration is not allowed when attributes are locked explicitly
        $table_schema = Cache::get($model->getTable());

        if (isset($table_schema['lock_attributes']) && $table_schema['lock_attributes']) {
            return true;
        }

        // Cached attributes
        $cached_attributes = array_map(function($item) { return $item['name']; }, isset($table_schema['attributes']) ? $table_schema['attributes'] : array());

        $config = array(
            'lock_attributes' => false,
            'attributes' => array()
        );

        foreach ($attributes as $field => $value) {
            // extract datatype from field value to migrate
            $datatype = strtolower(gettype($value));

            // ignore 'null' data-types
            if ($datatype == 'null') {
                unset($attributes[$field]);
                continue;
            }

            // Detect large text blocks to declare 'text' datatype.
            if ($datatype == 'string' && strlen($value) > 255) {
                $datatype = 'text';
            }

            if ($datatype !== 'array' && !in_array($field, $cached_attributes)) {
                $config['attributes'][] = array('name' => $field, 'type' => $datatype);
            }
        }

        if (count($config['attributes']) > 0) {
            return $this->migrate($model, $config, true);
        } else {
            return false;
        }
    }
1028284
public function fill(Identifiable $model, array $attributes)
    {
        $this->checkIsModel($model);

        $this->callBeforeListeners('fill', [$model, $attributes]);
        $filtered = $this->toModelAttributes($model, $attributes);

        /** @var EloquentModel $model */
        $beforeDirty = $model->isDirty();
        $this->performFill($model, $filtered);
        $changed = $beforeDirty || $model->isDirty();

        $this->callAfterListeners('fill', [$model, $attributes]);

        return $changed;
    }
1225678
public function copyForUpdateFrom( $model, $attributes = [] ) {

		foreach ( $attributes as $attribute ) {

			if( $this->hasAttribute( $attribute ) ) {

				$this->setAttribute( $attribute, $model->$attribute );
			}
			else {

				$this->$attribute = $model->$attribute;
			}
		}
	}