This commit is contained in:
2020-09-11 17:58:02 +08:00
parent 2d789b3494
commit 45aaf011f9
7 changed files with 66 additions and 48 deletions
+3 -3
View File
@@ -170,19 +170,19 @@ class Collection extends AbstractCollection
public function delete()
{
$model = $this->model;
if (!$model::hasPrimary()) {
if (!$model->hasPrimary()) {
return false;
}
$ids = [];
foreach ($this as $item) {
$ids[] = $item->{$model::getPrimary()};
$ids[] = $item->getPrimaryValue();
}
$ids = array_filter($ids);
if (empty($ids)) {
return false;
}
return $this->model::find()
->in($model::getPrimary(), $ids)
->in($model->getPrimary(), $ids)
->deleteAll();
}