Astrotomic / laravel-translatable

A Laravel package for multilingual models
https://docs.astrotomic.info/laravel-translatable/
MIT License
1.22k stars 153 forks source link

Fix model saving with guarded attributes #335

Closed slowcheetah closed 1 year ago

slowcheetah commented 1 year ago

Fix for issue #334

Added tests:

Gummibeer commented 1 year ago

That mutator on the main model for a translated attribute is absolutely not expected/supported - in case you have to mutate a translated attribute put that on the translation model.

    public function getNameAttribute()
    {
        $locale = 'En';
        $this->locale = $locale;

        return $this->translate(mb_strtolower($locale))->name;
    }