protected function getTranslation(string $locale): ?Model
    {
        if (isset($this->translationCache[$locale])) {
            return $this->translationCache[$locale];
        }

        if (!$this->exists) {
            return null;
        }

        $translation = $this->translations
            ->where('locale', $locale)
            ->first();

        if ($translation) {
            $this->translationCache[$locale] = $translation;
        }

        return $translation;
    }
protected function getTranslation(string $locale): ?Model
    {
        if (isset($this->translationCache[$locale])) {
            return $this->translationCache[$locale];
        }

        if (!$this->exists) {
            return null;
        }

        $translation = $this->translations
            ->where('locale', $locale)
            ->first();

        if ($translation) {
            $this->translationCache[$locale] = $translation;
        }

        return $translation;
    }
protected function getTranslation ( string $ locale ) : ? Model { if ( isset ( $ this -> translationCache [ $ locale ] ) ) { return $ this -> translationCache [ $ locale ] ; } if ( ! $ this -> exists ) { return null ; } $ translation = $ this -> translations -> where ( 'locale' , $ locale ) -> first ( ) ; if ( $ translation ) { $ this -> translationCache [ $ locale ] = $ translation ; } return $ translation ; }
Get a translation from cache, loaded relation, or database.

@param string $locale

@return \Illuminate\Database\Eloquent\Model|null
Get a translation from cache loaded relation or database .