Astrotomic / laravel-translatable

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

Problems with changing the attribute (value) of the current locale #238

Closed Basti007 closed 2 years ago

Basti007 commented 3 years ago

Hey, I've encountered the issue that I cannot update the locale that is currently being used. I think I've done something wrong but I'm not quite sure.

My code looks like this:

$this->category->fill([
    'name:de' => $this->nameGerman,
    'name:en' => $this->nameEnglish
]);
$this->category->save();

The variables contain the right values. The english name is updated if I set my locale to german but then the german name is not updated.

I hope that someone can help me :)

Gummibeer commented 3 years ago

If the package is properly configured this code will 100% work and do what is expected. So the issue lives in your configuration or the form request you are using.

Basti007 commented 3 years ago

What could be misconfigured that this part won't work? I've followed the installation in the docs and even with hardcoded values the value of the current locale won't change.

ordago commented 3 years ago

@Basti007 I had the same problem. Not ideal but as a workaround this would make it work. Before saving.

$this->category->unsetRelation('translation');
github-actions[bot] commented 3 years ago

This issue is stale because it has been open 21 days with no activity. Remove stale label or comment or this will be closed in 7 days