Skip to content

Commit

Permalink
fix issue 57
Browse files Browse the repository at this point in the history
  • Loading branch information
terrasoff committed Mar 30, 2018
1 parent 8149499 commit 0181f05
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions RelationTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,18 @@ public function saveAll($skippedRelations = [])
$query = ['and', $notDeletedFK, ['not in', $relPKAttr[0], $notDeletedPK]];
if (!empty($notDeletedPK)) {
try {
$notDeletedPK = array_filter($notDeletedPK);
if (empty($notDeletedPK)) {
// new record was added and old records were deleted
$query = [];
} else {
$query = [
'and',
$notDeletedFK,
['not in', $relPKAttr[0], $notDeletedPK]
];
}

if ($isSoftDelete) {
$relModel->updateAll($this->_rt_softdelete, $query);
} else {
Expand Down

0 comments on commit 0181f05

Please sign in to comment.