This commit is contained in:
2022-09-07 14:31:10 +08:00
parent e3169b1348
commit c7ad5123e2
2 changed files with 22 additions and 1 deletions
+21
View File
@@ -50,6 +50,27 @@ class Collection extends AbstractCollection
return $_tmp;
}
/**
* @param array $attributes
* @return bool
* @throws Exception
*/
public function update(array $attributes): bool
{
$lists = [];
$primary = $this->getModel()->getPrimary();
$items = $this->getItems();
if ($this->isEmpty() || !isset($items[0][$primary])) {
return false;
}
foreach ($items as $item) {
$lists[] = $item[$primary];
}
return $this->getModel()::query()->whereIn($primary, $lists)
->batchUpdate($attributes);
}
/**
* @param string $field
* @return array|null
+1 -1
View File
@@ -187,7 +187,7 @@ class Columns extends Component
*/
#[Pure] public function isJson($format): bool
{
return in_array($format, ['json']);
return $format == 'json';
}
/**