Skip to content

Commit

Permalink
🐛(repository): 修复多条件更新数据没有过滤掉不存在的字段
Browse files Browse the repository at this point in the history
  • Loading branch information
Joycezhangw committed Mar 13, 2024
1 parent 4c708e4 commit a6a42d6
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/Repositories/BaseRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -399,16 +399,18 @@ public function updateById(array $attributes, int $id)
* 根据指定条件更新数据,批量更新
* @param array $condition 更新条件
* @param array $attributes 要更新的字段
* @return bool|mixed
* @return mixed
* @throws RepositoryException
* @throws \Illuminate\Contracts\Container\BindingResolutionException
*/
public function updateByWhere(array $condition, array $attributes)
{
$this->applyConditions($condition);
$result = $this->model->update($attributes);
$model = $this->model->firstOrFail();
$model->fill($attributes);
$model->save();
$this->resetModel();
return $result;
return $model;
}

/**
Expand Down

0 comments on commit a6a42d6

Please sign in to comment.