From 2efbb5b7ec17d28b72b2a6b21fa07a71cf81ee75 Mon Sep 17 00:00:00 2001 From: Jonas Staudenmeir Date: Mon, 25 Mar 2019 02:15:04 +0100 Subject: [PATCH] Fix BelongsToMany::detach() with custom pivot class --- .../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 eec606ec2706..c8b3ae2c15ca 100644 --- a/src/Illuminate/Database/Eloquent/Relations/Concerns/InteractsWithPivotTable.php +++ b/src/Illuminate/Database/Eloquent/Relations/Concerns/InteractsWithPivotTable.php @@ -403,7 +403,7 @@ protected function hasPivotColumn($column) */ public function detach($ids = null, $touch = true) { - if ($this->using && ! empty($ids)) { + if ($this->using && ! empty($ids) && empty($this->pivotWheres) && empty($this->pivotWhereIns)) { $results = $this->detachUsingCustomClass($ids); } else { $query = $this->newPivotQuery();