Skip to content

Commit

Permalink
Fix use isInitializing
Browse files Browse the repository at this point in the history
  • Loading branch information
petrzpav committed Dec 10, 2024
1 parent 45e4fcd commit ca73a1b
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/Traits/Translatable.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ public function setAttribute($key, $value)
}

$locale = app()->getLocale();
if ($this->isInitializing) {
// do not set translations into database during initialization phase
if (! $this->isInitializing) {
$this->setTranslation($key, $locale, $value);
}

Expand All @@ -67,8 +68,8 @@ public function setAttribute($key, $value)
public function translate($attribute, $locale, $fallbackLocale)
{
$cacheKey = $this->getTranslationCacheKey($attribute, $locale, $fallbackLocale);

$cachedValue = Cache::get($cacheKey);

// use NULL_PLACEHOLDER to cache null values
if ($cachedValue === self::NULL_PLACEHOLDER) {
return null;
Expand Down

0 comments on commit ca73a1b

Please sign in to comment.