From 24f34792203b520a316abd1922fe57a14e3c825b Mon Sep 17 00:00:00 2001 From: Adrien Foulon <6115458+Tofandel@users.noreply.github.com> Date: Tue, 2 Jul 2024 17:56:54 +0200 Subject: [PATCH] [11.x] Fix sync is running touch query twice (#51984) * Fix sync is running touch query twice * Update InteractsWithPivotTable.php --------- Co-authored-by: Taylor Otwell --- .../Eloquent/Relations/Concerns/InteractsWithPivotTable.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Illuminate/Database/Eloquent/Relations/Concerns/InteractsWithPivotTable.php b/src/Illuminate/Database/Eloquent/Relations/Concerns/InteractsWithPivotTable.php index 48444a52db85..c39398e6cd36 100644 --- a/src/Illuminate/Database/Eloquent/Relations/Concerns/InteractsWithPivotTable.php +++ b/src/Illuminate/Database/Eloquent/Relations/Concerns/InteractsWithPivotTable.php @@ -102,7 +102,7 @@ public function sync($ids, $detaching = true) $detach = array_diff($current, array_keys($records)); if (count($detach) > 0) { - $this->detach($detach); + $this->detach($detach, false); $changes['detached'] = $this->castKeys($detach); }