Skip to content

Commit ea5299d

Browse files
committed
Fixes #256
1 parent 5bd7ee6 commit ea5299d

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/Jenssegers/Mongodb/Relations/BelongsToMany.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ public function sync($ids, $detaching = true)
6060
// if they exist in the array of current ones, and if not we will insert.
6161
$current = $this->parent->{$this->otherKey} ?: array();
6262

63+
// See issue #256.
64+
if ($current instanceof Collection) $current = $ids->modelKeys();
65+
6366
$records = $this->formatSyncList($ids);
6467

6568
$detach = array_diff($current, array_keys($records));

0 commit comments

Comments
 (0)