public function setTranslation($key, $locale, $value)
    {
        $this->guardAgainstNonTranslatableAttribute($key);

        $translations = $this->getTranslations($key);
        $oldValue     = $translations[$locale] ?? '';

        if ($this->hasSetMutator($key)) {
            $this->{'set'.Str::studly($key).'Attribute'}($value);
            $value = $this->attributes[$key];
        }

        $translations[$locale]  = $value;
        $this->attributes[$key] = $this->asJson($translations);

        event(new TranslationHasBeenSet($this, $key, $locale, $oldValue, $value));

        return $this;
    }
public function setTranslation($key, $locale, $value)
    {
        $this->guardAgainstNonTranslatableAttribute($key);

        $translations = $this->getTranslations($key);
        $oldValue     = $translations[$locale] ?? '';

        if ($this->hasSetMutator($key)) {
            $this->{'set'.Str::studly($key).'Attribute'}($value);
            $value = $this->attributes[$key];
        }

        $translations[$locale]  = $value;
        $this->attributes[$key] = $this->asJson($translations);

        event(new TranslationHasBeenSet($this, $key, $locale, $oldValue, $value));

        return $this;
    }
public function setTranslation ( $ key , $ locale , $ value ) { $ this -> guardAgainstNonTranslatableAttribute ( $ key ) ; $ translations = $ this -> getTranslations ( $ key ) ; $ oldValue = $ translations [ $ locale ] ?? '' ; if ( $ this -> hasSetMutator ( $ key ) ) { $ this -> { 'set' . Str :: studly ( $ key ) . 'Attribute' } ( $ value ) ; $ value = $ this -> attributes [ $ key ] ; } $ translations [ $ locale ] = $ value ; $ this -> attributes [ $ key ] = $ this -> asJson ( $ translations ) ; event ( new TranslationHasBeenSet ( $ this , $ key , $ locale , $ oldValue , $ value ) ) ; return $ this ; }
Set a translation.

@param  string  $key
@param  string  $locale
@param  string  $value

@return self
Set a translation .