From 94da2c8c3d1113517135eaacd6b32ee573024994 Mon Sep 17 00:00:00 2001 From: joycezhang <787027175@qq.com> Date: Mon, 18 Mar 2024 02:07:18 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B(repository):=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E5=A4=9A=E6=9D=A1=E4=BB=B6=E6=9B=B4=E6=96=B0=E6=9D=A1=E4=BB=B6?= =?UTF-8?q?=E6=97=A0=E6=B3=95=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Repositories/BaseRepository.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/Repositories/BaseRepository.php b/src/Repositories/BaseRepository.php index 2ebdc85..b47e140 100644 --- a/src/Repositories/BaseRepository.php +++ b/src/Repositories/BaseRepository.php @@ -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();