We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent f4c448f commit 1b71ae4Copy full SHA for 1b71ae4
src/Relations/BelongsToMany.php
@@ -8,6 +8,7 @@
8
use Illuminate\Database\Eloquent\Model as EloquentModel;
9
use Illuminate\Database\Eloquent\Relations\BelongsToMany as EloquentBelongsToMany;
10
use Illuminate\Support\Arr;
11
+use Jenssegers\Mongodb\Eloquent\Model as MongodbModel;
12
13
class BelongsToMany extends EloquentBelongsToMany
14
{
@@ -122,7 +123,9 @@ public function sync($ids, $detaching = true)
122
123
124
if ($ids instanceof Collection) {
125
$ids = $ids->modelKeys();
- }
126
+ } else if ($ids instanceof MongodbModel) {
127
+ $ids = [$ids->{$this->relatedKey}];
128
+ }
129
130
// First we need to attach any of the associated models that are not currently
131
// in this joining table. We'll spin through the given IDs, checking to see
0 commit comments