Skip to content

Commit

Permalink
🐛(repository): 修复多条件更新条件无法查询
Browse files Browse the repository at this point in the history
Joycezhangw committed Mar 17, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent 7c7393a commit 94da2c8
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/Repositories/BaseRepository.php
Original file line number Diff line number Diff line change
@@ -405,8 +405,7 @@ public function updateById(array $attributes, int $id)
*/
public function updateByWhere(array $condition, array $attributes)
{
$this->applyConditions($condition);
$model = $this->model->firstOrFail();
$model = $this->model->where($condition)->firstOrFail();
$model->fill($attributes);
$model->save();
$this->resetModel();
@@ -424,7 +423,7 @@ public function updateByWhere(array $condition, array $attributes)
*/
public function updateFieldById(int $id, string $filedName, string $fieldValue)
{
$model = $this->model->find($id);
$model = $this->model->findOrFail($id);
$model->$filedName = $fieldValue;
$result = $model->save();
$this->resetModel();

0 comments on commit 94da2c8

Please sign in to comment.