From aa355daeeac525d0d2d0a1a05b3df6d3ec4d5b15 Mon Sep 17 00:00:00 2001 From: Quinten Buis Date: Sat, 8 Oct 2022 20:17:11 +0200 Subject: [PATCH] Change relation() to use the new ofMany --- src/Translatable/Traits/Relationship.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Translatable/Traits/Relationship.php b/src/Translatable/Traits/Relationship.php index 1a4cc1c..77f41cd 100644 --- a/src/Translatable/Traits/Relationship.php +++ b/src/Translatable/Traits/Relationship.php @@ -65,7 +65,11 @@ public function translation(): HasOne { return $this ->hasOne($this->getTranslationModelName(), $this->getTranslationRelationKey()) - ->where($this->getLocaleKey(), $this->localeOrFallback()); + ->ofMany([ + $this->getTranslationRelationKey() => 'max', + ], function ($query) { + $query->where($this->getLocaleKey(), $this->localeOrFallback()); + }); } protected function localeOrFallback()