Skip to content
This repository has been archived by the owner on Jun 18, 2019. It is now read-only.

Commit

Permalink
fix getAttributeOrFallback()
Browse files Browse the repository at this point in the history
  • Loading branch information
Gummibeer committed Jul 24, 2018
1 parent b2130c3 commit 40e6c39
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/Translatable/Translatable.php
Expand Up @@ -161,17 +161,23 @@ private function usePropertyFallback()
*/
private function getAttributeOrFallback($locale, $attribute)
{
$value = $this->getTranslation($locale)->$attribute;
$translation = $this->getTranslation($locale);

if (
empty($value) &&
$this->usePropertyFallback() &&
($fallback = $this->getTranslation($this->getFallbackLocale(), true))
(
!$translation instanceof Model ||
empty($translation->$attribute)
) &&
$this->usePropertyFallback()
) {
return $fallback->$attribute;
$translation = $this->getTranslation($this->getFallbackLocale(), true);
}

return $value;
if ($translation instanceof Model) {
return $translation->$attribute;
}

return null;
}

/**
Expand Down

0 comments on commit 40e6c39

Please sign in to comment.