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.
2 parents aa902de + 2d052a3 commit 73d4b0bCopy full SHA for 73d4b0b
laravel/database/eloquent/relationships/has_many_and_belongs_to.php
@@ -121,6 +121,7 @@ public function detach($ids)
121
public function sync($ids)
122
{
123
$current = $this->pivot()->lists($this->other_key());
124
+ $ids = (array) $ids;
125
126
// First we need to attach any of the associated models that are not currently
127
// in the joining table. We'll spin through the given IDs, checking to see
@@ -140,7 +141,7 @@ public function sync($ids)
140
141
142
if (count($detach) > 0)
143
- $this->detach(array_diff($current, $ids));
144
+ $this->detach($detach);
145
}
146
147
0 commit comments