Skip to content

Commit 09a6d44

Browse files
committed
Update SystemService.php
1 parent 3a3d2ce commit 09a6d44

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

src/service/SystemService.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,7 @@ public static function update($query, array $data, string $key = 'id', $map = []
191191
try {
192192
$query = Helper::buildQuery($query)->master()->where($map);
193193
if (empty($map[$key])) $query->where([$key => $data[$key] ?? null]);
194-
$model = (clone $query)->findOrEmpty();
195-
return $model->isExists() ? (clone $query)->strict(false)->update($data) : $model->save($data);
194+
return (clone $query)->count() > 1 ? $query->strict(false)->update($data) : $query->findOrEmpty()->save($data);
196195
} catch (\Exception|\Throwable $exception) {
197196
throw new Exception($exception->getMessage(), $exception->getCode());
198197
}

0 commit comments

Comments
 (0)