From 33aee31523b9fc280aced35a5eb5f6b627263b45 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Mon, 15 Aug 2016 08:38:37 -0500 Subject: [PATCH] add sync without detaching method --- .../Database/Eloquent/Relations/BelongsToMany.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/Illuminate/Database/Eloquent/Relations/BelongsToMany.php b/src/Illuminate/Database/Eloquent/Relations/BelongsToMany.php index ed05d8448ef3..51b3c9479a67 100755 --- a/src/Illuminate/Database/Eloquent/Relations/BelongsToMany.php +++ b/src/Illuminate/Database/Eloquent/Relations/BelongsToMany.php @@ -795,6 +795,17 @@ public function createMany(array $records, array $joinings = []) return $instances; } + /** + * Sync the intermediate tables with a list of IDs without detaching. + * + * @param \Illuminate\Database\Eloquent\Collection|array $ids + * @return array + */ + public function syncWithoutDetaching($ids) + { + return $this->sync($ids, false); + } + /** * Sync the intermediate tables with a list of IDs or collection of models. *