From 1a91c00df7662854d7e887158b957439803725b5 Mon Sep 17 00:00:00 2001 From: Viacheslav Ostrovskiy Date: Mon, 20 Apr 2020 12:21:34 +0300 Subject: [PATCH] =?UTF-8?q?Fixed=20not=20=C2=ABid=C2=BB=20primary=20key?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/BelongsToMany.php | 2 +- src/MorphToMany.php | 2 +- src/MorphedByMany.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/BelongsToMany.php b/src/BelongsToMany.php index 15e0a4e..425e5dd 100644 --- a/src/BelongsToMany.php +++ b/src/BelongsToMany.php @@ -105,7 +105,7 @@ public function attach($id, array $attributes = [], $touch = true) public function detach($ids = null, $touch = true) { // Get detached ids to pass them to event - $ids = $ids ?? $this->parent->{$this->getRelationName()}->pluck('id'); + $ids = $ids ?? $this->parent->{$this->getRelationName()}->pluck($this->relatedKey); $this->parent->fireModelBelongsToManyEvent('detaching', $this->getRelationName(), $ids); diff --git a/src/MorphToMany.php b/src/MorphToMany.php index 3ebe448..e3628f8 100644 --- a/src/MorphToMany.php +++ b/src/MorphToMany.php @@ -103,7 +103,7 @@ public function attach($id, array $attributes = [], $touch = true) public function detach($ids = null, $touch = true) { // Get detached ids to pass them to event - $ids = $ids ?? $this->parent->{$this->getRelationName()}->pluck('id'); + $ids = $ids ?? $this->parent->{$this->getRelationName()}->pluck($this->relatedKey); $this->parent->fireModelMorphToManyEvent('detaching', $this->getRelationName(), $ids); diff --git a/src/MorphedByMany.php b/src/MorphedByMany.php index b932b39..e7303c7 100644 --- a/src/MorphedByMany.php +++ b/src/MorphedByMany.php @@ -103,7 +103,7 @@ public function attach($id, array $attributes = [], $touch = true) public function detach($ids = null, $touch = true) { // Get detached ids to pass them to event - $ids = $ids ?? $this->parent->{$this->getRelationName()}->pluck('id'); + $ids = $ids ?? $this->parent->{$this->getRelationName()}->pluck($this->relatedKey); $this->parent->fireModelMorphedByManyEvent('detaching', $this->getRelationName(), $ids);