From 627587878731650c52d79e2132cfd1410a18d428 Mon Sep 17 00:00:00 2001 From: Jordan Miguel Date: Fri, 19 Jan 2024 19:10:13 -0300 Subject: [PATCH] fix: Fixing issue when using a different table to store pivot data (#492) --- src/HasTags.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/HasTags.php b/src/HasTags.php index 959b1b0..4f5b24c 100644 --- a/src/HasTags.php +++ b/src/HasTags.php @@ -57,7 +57,7 @@ public static function bootHasTags() public function tags(): MorphToMany { return $this - ->morphToMany(self::getTagClassName(), $this->getTaggableMorphName()) + ->morphToMany(self::getTagClassName(), $this->getTaggableMorphName(), $this->getTaggableTableName()) ->using($this->getPivotModelClassName()) ->ordered(); } @@ -67,7 +67,7 @@ public function tagsTranslated(string | null $locale = null): MorphToMany $locale = ! is_null($locale) ? $locale : self::getTagClassName()::getLocale(); return $this - ->morphToMany(self::getTagClassName(), $this->getTaggableMorphName()) + ->morphToMany(self::getTagClassName(), $this->getTaggableMorphName(), $this->getTaggableTableName()) ->using($this->getPivotModelClassName()) ->select('*') ->selectRaw("JSON_UNQUOTE(JSON_EXTRACT(name, '$.\"{$locale}\"')) as name_translated")