public function setTranslation(string $key, string $value = null, string $locale = null)
    {
        $this->throwExceptionIfAttributeIsNotTranslatable($key);

        $locale = $locale ?: config('app.locale');

        $translations = $this->getTranslations($key);

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

        $translations[$locale] = $value;

        $this->attributes[$key] = json_encode($translations);

        return $this;
    }
public function setTranslation(string $key, string $value = null, string $locale = null)
    {
        $this->throwExceptionIfAttributeIsNotTranslatable($key);

        $locale = $locale ?: config('app.locale');

        $translations = $this->getTranslations($key);

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

        $translations[$locale] = $value;

        $this->attributes[$key] = json_encode($translations);

        return $this;
    }
public function setTranslation ( string $ key , string $ value = null , string $ locale = null ) { $ this -> throwExceptionIfAttributeIsNotTranslatable ( $ key ) ; $ locale = $ locale ? : config ( 'app.locale' ) ; $ translations = $ this -> getTranslations ( $ key ) ; if ( $ this -> hasSetMutator ( $ key ) ) { $ value = $ this -> { 'set' . Str :: studly ( $ key ) . 'Attribute' } ( $ value ) ; } $ translations [ $ locale ] = $ value ; $ this -> attributes [ $ key ] = json_encode ( $ translations ) ; return $ this ; }
Set attribute translation.

@param  string      $key
@param  string      $value
@param  string|null $locale
@return mixed
Set attribute translation .