diff --git a/src/Illuminate/Database/Eloquent/Relations/Concerns/InteractsWithPivotTable.php b/src/Illuminate/Database/Eloquent/Relations/Concerns/InteractsWithPivotTable.php index 695d0bc77656..eec606ec2706 100644 --- a/src/Illuminate/Database/Eloquent/Relations/Concerns/InteractsWithPivotTable.php +++ b/src/Illuminate/Database/Eloquent/Relations/Concerns/InteractsWithPivotTable.php @@ -184,7 +184,7 @@ protected function attachNew(array $records, array $current, $touch = true) */ public function updateExistingPivot($id, array $attributes, $touch = true) { - if ($this->using) { + if ($this->using && empty($this->pivotWheres) && empty($this->pivotWhereIns)) { return $this->updateExistingPivotUsingCustomClass($id, $attributes, $touch); } @@ -403,7 +403,7 @@ protected function hasPivotColumn($column) */ public function detach($ids = null, $touch = true) { - if ($this->using) { + if ($this->using && ! empty($ids)) { $results = $this->detachUsingCustomClass($ids); } else { $query = $this->newPivotQuery();