Form Tabs not saving the correct relationship content.
So I have a form that has an Tab that handles the translation of some fields, like
The example above shows that
I built and trait that helps getting the correct model with above structure. Trait
What happens is that the correct values are shown, but when I press the save button, the current visible
Here is an simplified code of how
title and description of a model. What is happening is that for now the app has 3 basic languages, more will be add later. To make this possible every translatable model has an i18n table counterpart. This i18n has one column per translatable property of the model together with the composite primary key model_id and locale, here is an example:The example above shows that
Model will not have title and description fields. It will be saved on the i18n one with their respective locale, en_CA, fr_CA and etc.I built and trait that helps getting the correct model with above structure. Trait
What happens is that the correct values are shown, but when I press the save button, the current visible
Tab overwrites all others locales. So if a save when en_CA tab is visible, the tab holding the values for fr_CA will be overwritten.Here is an simplified code of how
Tabs was built:Gist
Laravel Translatable model with magic method. GitHub Gist: instantly share code, notes, and snippets.
