diff --git a/src/HasTranslations.php b/src/HasTranslations.php index 9645edc..d54acbf 100644 --- a/src/HasTranslations.php +++ b/src/HasTranslations.php @@ -67,11 +67,6 @@ public function translate(string $key, string $locale = '', bool $useFallbackLoc public function getTranslation(string $key, string $locale, bool $useFallbackLocale = true): mixed { - // if column value is `null` then we have nothing to do, return `null` - if (is_null(parent::getAttributeFromArray($key))) { - return null; - } - $normalizedLocale = $this->normalizeLocale($key, $locale, $useFallbackLocale); $isKeyMissingFromLocale = ($locale !== $normalizedLocale); diff --git a/tests/TranslatableTest.php b/tests/TranslatableTest.php index 7597115..c068f75 100644 --- a/tests/TranslatableTest.php +++ b/tests/TranslatableTest.php @@ -854,7 +854,7 @@ public function setAttributesExternally(array $attributes) [['en' => 'english', 'nl' => 'dutch'], ['en', 'nl'], ['english', 'dutch']], ]); -it('should return null when the underlying attribute in database is null', function () { +it('should return empty string when the underlying attribute in database is null', function () { // we need to remove the name attribute from the translatable array // and add it back to make sure the name // attribute is holding `null` raw value @@ -864,7 +864,7 @@ public function setAttributesExternally(array $attributes) $translation = $this->testModel->getTranslation('name', 'en'); - expect($translation)->toBeNull(); + expect($translation)->toBe(''); }); it('should return locales with empty string translations when allowEmptyStringForTranslation is true', function () {