perf: DatabaseAdapter::updatePolicy return early if not exists

This commit is contained in:
Cidos 2022-11-01 14:53:03 +08:00
parent 440bc229f6
commit 7e21d0c98b
1 changed files with 5 additions and 1 deletions

View File

@ -256,7 +256,11 @@ class DatabaseAdapter implements DatabaseAdapterContract, BatchDatabaseAdapterCo
foreach($oldRule as $k => $v) {
$instance->where('v' . $k, $v);
}
$instance->first();
$instance = $instance->first();
if (!$instance) {
return;
}
$update = [];
foreach($newPolicy as $k => $v) {
$update['v' . $k] = $v;