Skip to content

Commit 0e61e70

Browse files
committed
Update RelationTrait.php
1 parent d3062f5 commit 0e61e70

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

RelationTrait.php

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -192,14 +192,16 @@ public function saveAll()
192192
$error = true;
193193
}
194194
}else{
195-
foreach ($rel['link'] as $k => $v) {
196-
$condition[] = $k . " = " . $this->$v;
197-
}
198-
try {
199-
$relModel->deleteAll(implode(" AND ", $condition));
200-
} catch (\yii\db\IntegrityException $exc) {
201-
$this->addError($rel['name'], "Data can't be deleted because it's still used by another data.");
202-
$error = true;
195+
if($rel['ismultiple']){
196+
foreach ($rel['link'] as $k => $v) {
197+
$condition[] = $k . " = " . $this->$v;
198+
}
199+
try {
200+
$relModel->deleteAll(implode(" AND ", $condition));
201+
} catch (\yii\db\IntegrityException $exc) {
202+
$this->addError($rel['name'], "Data can't be deleted because it's still used by another data.");
203+
$error = true;
204+
}
203205
}
204206
}
205207
}

0 commit comments

Comments
 (0)