diff --git a/src/Relations/BelongsToManyCustom.php b/src/Relations/BelongsToManyCustom.php index 2b9c0d1..a8cd2d6 100644 --- a/src/Relations/BelongsToManyCustom.php +++ b/src/Relations/BelongsToManyCustom.php @@ -35,7 +35,7 @@ public function attach($ids, array $attributes = [], $touch = true) public function detach($ids = null, $touch = true) { if (is_null($ids)) { - $ids = $this->query->pluck($this->query->qualifyColumn('id'))->toArray(); + $ids = $this->query->pluck($this->query->qualifyColumn($this->relatedKey))->toArray(); } list($idsOnly) = $this->getIdsWithAttributes($ids);