Skip to content

Commit a25ef40

Browse files
Fix, detach with Objectid
1 parent c004cf6 commit a25ef40

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/Relations/BelongsToMany.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,11 @@ public function detach($ids = [], $touch = true)
235235
// If associated IDs were passed to the method we will only delete those
236236
// associations, otherwise all of the association ties will be broken.
237237
// We'll return the numbers of affected rows when we do the deletes.
238-
$ids = (array) $ids;
238+
if ($ids instanceof \MongoDB\BSON\ObjectId) {
239+
$ids = [$ids];
240+
} else {
241+
$ids = (array) $ids;
242+
}
239243

240244
// Detach all ids from the parent model.
241245
if ($this->parent instanceof \MongoDB\Laravel\Eloquent\Model) {

0 commit comments

Comments
 (0)