Skip to content

Commit

Permalink
fix: 优化 SystemService::update 方法
Browse files Browse the repository at this point in the history
  • Loading branch information
zoujingli committed Feb 23, 2025
1 parent 4bace3b commit c0c64a4
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/service/SystemService.php
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ public static function update($query, array $data, string $key = 'id', $map = []
try {
$query = Helper::buildQuery($query)->master()->strict(false)->where($map);
if (empty($map[$key])) $query->where([$key => $data[$key] ?? null]);
return (clone $query)->count() > 0 ? (clone $query)->update($data) : (clone $query)->save($data);
return (clone $query)->count() > 0 ? (clone $query)->update($data) : (clone $query)->findOrEmpty()->save($data);
} catch (\Exception $exception) {
throw new Exception($exception->getMessage(), $exception->getCode());
}
Expand Down

0 comments on commit c0c64a4

Please sign in to comment.