From da1de0371016a79f093e7a815356afdfce2e937e Mon Sep 17 00:00:00 2001 From: Gabriel Solomon Date: Sun, 21 Aug 2016 16:17:54 +0300 Subject: [PATCH] fix getWithClass for HABTM relations --- src/Records/Relations/HasAndBelongsToMany.php | 8 ++++++-- src/Records/Relations/Relation.php | 7 ++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/Records/Relations/HasAndBelongsToMany.php b/src/Records/Relations/HasAndBelongsToMany.php index d4aa7c9f..1d28add2 100644 --- a/src/Records/Relations/HasAndBelongsToMany.php +++ b/src/Records/Relations/HasAndBelongsToMany.php @@ -74,6 +74,7 @@ protected function initJoinFields() /** * Simple select query from the link table + * @param bool $specific * @return Query */ public function getLinkQuery($specific = true) @@ -91,8 +92,6 @@ public function getLinkQuery($specific = true) return $query; } - - /** * @param RecordCollection $collection * @return RecordCollection @@ -168,6 +167,11 @@ protected function _delete() } + public function getWithClass() + { + return $this->getName(); + } + /** * @return Connection */ diff --git a/src/Records/Relations/Relation.php b/src/Records/Relations/Relation.php index 4b8ad9c7..395b99bc 100644 --- a/src/Records/Relations/Relation.php +++ b/src/Records/Relations/Relation.php @@ -216,10 +216,15 @@ public function getWith() public function initWith() { - $className = inflector()->pluralize($this->getName()); + $className = $this->getWithClass(); $this->setWithClass($className); } + public function getWithClass() + { + return inflector()->pluralize($this->getName()); + } + /** * @param string $name */