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();