本文整理汇总了PHP中Illuminate\Database\Eloquent\Builder::update方法的典型用法代码示例。如果您正苦于以下问题:PHP Builder::update方法的具体用法?PHP Builder::update怎么用?PHP Builder::update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Database\Eloquent\Builder
的用法示例。
在下文中一共展示了Builder::update方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addRestore
/**
* Add the restore extension to the builder.
*
* @param \Illuminate\Database\Eloquent\Builder $builder
* @return void
*/
protected function addRestore(Builder $builder)
{
$builder->macro('restore', function (Builder $builder) {
$builder->withTrashed();
return $builder->update([$builder->getModel()->getDeletedAtColumn() => 'publish']);
});
}
示例2: update
public function update(array $values)
{
foreach ($values as $key => &$value) {
if ($value instanceof GeometryInterface) {
$value = $this->asWKT($value);
}
}
return parent::update($values);
}
示例3: update
/**
* Update a record in the database.
*
* @param array $values
* @return int
*/
public function update(array $values)
{
// Intercept operations on embedded models and delegate logic
// to the parent relation instance.
if ($relation = $this->model->getParentRelation()) {
$relation->performUpdate($this->model, $values);
return 1;
}
return parent::update($values);
}
示例4: update
/**
* @param array $entity
*
* @return bool
*/
public function update($entity)
{
$data = $this->mapper->toDbTableRow($entity);
$this->specificationQuery->update($data->toArray());
return true;
}
示例5: rawUpdate
/**
* Run a raw update against the base query.
*
* @param array $attributes
* @return int
*/
public function rawUpdate(array $attributes = [])
{
return $this->query->update($attributes);
}
示例6: addReject
/**
* Add the Reject extension to the builder.
*
* @param \Illuminate\Database\Eloquent\Builder $builder
*
* @return void
*/
protected function addReject(Builder $builder)
{
$builder->macro('reject', function (Builder $builder, $id = null) {
$builder->withAnyStatus();
//If $id parameter is passed then update the specified model
if ($id) {
$model = $builder->find($id);
$model->{$model->getStatusColumn()} = Status::REJECTED;
$model->{$model->getModeratedAtColumn()} = Carbon::now();
return $model->save();
}
return $builder->update([$builder->getModel()->getStatusColumn() => Status::REJECTED, $builder->getModel()->getModeratedAtColumn() => Carbon::now()]);
});
}
示例7: update
/**
* Update a record in the database.
*
* @param array $values
* @return int
*/
public function update(array $values)
{
$this->model->fireEvent('updatingMultiple');
$return = parent::update($values);
$this->model->fireEvent('updatedMultiple');
return $return;
}
示例8: addDoFeature
/**
* Add the restore extension to the builder.
*
* @param \Illuminate\Database\Eloquent\Builder $builder
* @return void
*/
protected function addDoFeature(Builder $builder)
{
$builder->macro('dofeature', function (Builder $builder) {
return $builder->update([$builder->getModel()->getFeaturedAtColumn() => $builder->getModel()->freshTimestampString()]);
});
}
示例9: update
public function update(array $values)
{
if ($this->eagerLoad) {
$this->prepareQuery();
$this->buildRelationshipTree();
$this->applyRelationshipQuery($this->relations);
$this->reformatQueryComponents();
}
parent::update($values);
}
示例10: updateModerationStatus
/**
* @param \Illuminate\Database\Eloquent\Builder $builder
* @param $id
* @param $status
*
* @return bool|int
*/
private function updateModerationStatus(Builder $builder, $id, $status)
{
//If $id parameter is passed then update the specified model
if ($id) {
$model = $builder->find($id);
$model->{$model->getStatusColumn()} = $status;
$model->{$model->getModeratedAtColumn()} = Carbon::now();
//if moderated_by in enabled then append it to the update
if ($moderated_by = $model->getModeratedByColumn()) {
$model->{$moderated_by} = \Auth::user()->getKey();
}
$model->save();
return $model;
}
$update = [$builder->getModel()->getStatusColumn() => $status, $builder->getModel()->getModeratedAtColumn() => Carbon::now()];
//if moderated_by in enabled then append it to the update
if ($moderated_by = $builder->getModel()->getModeratedByColumn()) {
$update[$builder->getModel()->getModeratedByColumn()] = \Auth::user()->getKey();
}
return $builder->update($update);
}