cakephp-fixture-factories
cakephp-fixture-factories copied to clipboard
Creating multiple translations using shadowStrategy
Hi,
I have an article with translated name and description. I use the shadow strategy.
If I want to create multiple translations for an article, I need to pass this:
$article = ArticleFactory::make()
->withArticlesTranslations(
[
[
'id' => 1,
'locale' => 'fr',
'name' => 'Français',
'description' => 'Une phrase',
],
[
'id' => 1,
'locale' => 'en',
'name' => 'English',
'description' => 'A sentence',
],
]
)
->persist();
If I do this, the translations do persist in the database and the id is corrected by cakephp to the article id.
I I omit the 'id', then the translation do not get persisted.
It does not feel intuitive nor very nice to add an id that doesn't mean anything.
I use Cakephp 4.4
Hi,
normally you should not need to add this id
. How is the association between Articles
and ArticlesTranslations
defined in the ArticlesTable
and in the ArticlesTranslationsTable
?