Update the given model in the index.

@param Collection $models

@return void
762261
public function update($models)
    {
        $this->initIndex($models->first());
        $this->tnt->selectIndex("{$models->first()->searchableAs()}.index");
        $index = $this->tnt->getIndex();
        $index->setTokenizer($this->tnt->tokenizer);
        $index->setPrimaryKey($models->first()->getKeyName());

        if (isset($this->tnt->config['stopwords'])) {
            $index->setStopWords((array) $this->tnt->config['stopwords']);
        }

        $index->indexBeginTransaction();
        $models->each(function ($model) use ($index) {
            $array = $model->toSearchableArray();

            if (empty($array)) {
                return;
            }

            if ($model->getKey()) {
                $index->update($model->getKey(), $array);
            } else {
                $index->insert($array);
            }
        });
        $index->indexEndTransaction();
    }
945173
public function update(Model $model) {

		return $this->_populate(
			$this->_request('put', $this->_getUrl('element', $model->getPrimaryKey()), [
				'json' => $model->getAttributes()
			]),
			false
		);
	}
21519
public function handleModels(array $models)
    {
        $builder = $this->builder;

        $builder->start();

        foreach ($models as $model) {
            $languages = (array)(isset($model->sitemapLanguages) ? $model->sitemapLanguages : Yii::$app->language);

            if (count($languages) > 1) {
                // Handle separately for each language
                foreach ($languages as $language) {
                    // Swith App language to $language
                    if (isset($model->sitemapSwithLanguages) && $model->sitemapSwithLanguages) {
                        static::setLanguage($language);
                    }

                    $this->handleModel($model, $language);

                    // Restore App language
                    static::restoreLanguage();
                }
            } else {
                // Handle only one language
                $this->handleModel($model, null);
            }
        }

        $builder->finish();
    }
310035
public <T extends Model>  void addModels(List<T> models){
        for (T model : models) {
            add(model);
        }
    }
1146008
public function setExtraModelValues(array $fields, &$model)
    {
        //make sure the relationships are loaded
        foreach ($fields as $name => $field) {
            if ($field->getOption('relationship')) {
                $this->setModelRelationship($model, $field);
            }

            //if this is a setter field, unset it
            if ($field->getOption('setter')) {
                $model->__unset($name);
            }
        }
    }
471883
public function update(array $items = [])
    {
        foreach ($items as $key => $item) {
            $this->set($key, $item);
        }
    }
180472
protected function updateCollection($collection_id)
    {
        if (!$this->isError() && !$this->collection->update($collection_id, $this->getSubmitted())) {
            $this->errorAndExit($this->text('Unexpected result'));
        }
    }
20438
final public function updateCollectionObject() {
		if (!empty($this->collection_object) && !empty($this->collection)) {
			$this->collection_object->data = array_merge_hard($this->collection_object->data, $this->collection);
		}
	}
556735
public function setModel(Model $model)
    {
        parent::setModel($model);

        if ($model->exists) {
            $this->setInstance($model);
            $this->loadRelationValues();
        }
    }
518707
protected static function isSomeArr($models) {
        if (!is_array($models)) {
            return false;
        }
        $model = reset($models);
        return is_array($model) || $model instanceof Model;
    }
279457
public function delete($models)
    {
        $params['body'] = [];

        $models->each(function($model) use (&$params)
        {
            $params['body'][] = [
                'delete' => [
                    '_id' => $model->getKey(),
                    '_index' => $this->index,
                    '_type' => $model->searchableAs(),
                ]
            ];
        });

        $this->elastic->bulk($params);
    }
438916
public function updateCollection(Collection $collection): void
    {
        $query = $this->connection->createQueryBuilder();
        $query
            ->update('ngbm_collection')
            ->set('start', ':start')
            ->set('length', ':length')
            ->set('translatable', ':translatable')
            ->set('main_locale', ':main_locale')
            ->set('always_available', ':always_available')
            ->where(
                $query->expr()->eq('id', ':id')
            )
            ->setParameter('id', $collection->id, Type::INTEGER)
            ->setParameter('start', $collection->offset, Type::INTEGER)
            ->setParameter('length', $collection->limit, Type::INTEGER)
            ->setParameter('translatable', $collection->isTranslatable, Type::BOOLEAN)
            ->setParameter('main_locale', $collection->mainLocale, Type::STRING)
            ->setParameter('always_available', $collection->alwaysAvailable, Type::BOOLEAN);

        $this->applyStatusCondition($query, $collection->status);

        $query->execute();
    }
1071566
public function saveAll($models)
	{
		foreach ($models as $model)
		{
			if (!$this->associate($model)->save())
			{
				return false;
			}
		}

		return true;
	}
872906
protected function run($models)
    {
        $models = collect($models);
        if ($models->count() > 0) {
            $model = $models->first();

            if (!is_object($model)) {
                return;
            }

            if (!$this->isCascadable($model)) {
                return;
            }

            if (!in_array($model->getConnectionName(), $this->dbsToTransact)) {
                $this->dbsToTransact[] = $model->getConnectionName();
                DB::connection($model->getConnectionName())->beginTransaction();
            }

            $this->relations($model, $models->pluck($model->getKeyName()));
        }
    }
273791
public function addEagerConstraints(array $models)
    {
        parent::addEagerConstraints($models);

        if (is_array($this->foreignKeys[0])) {
            $column = $this->throughParent->qualifyColumn($this->foreignKeys[0][0]);

            $this->query->where($column, '=', $this->farParent->getMorphClass());
        }
    }
941053
protected function processSomeAttachments(Collection $models, array $attachments)
    {
        $progress = $this->getProgressBar($models);
        $progress->start();

        foreach ($models as $model) {
            $progress->advance();

            foreach ($model->getAttachedFiles() as $attachedFile) {
                if (in_array($attachedFile->name, $attachments)) {
                    $attachedFile->reprocess();
                }
            }
        }

        $progress->finish();
    }
987318
public function toManage($models, array $attributes = [])
    {
        if (is_array($models)) {
            foreach ($models as $model) {
                $this->to('*', $model, $attributes);
            }
        } else {
            $this->to('*', $models, $attributes);
        }
    }