Constant Variable
03/15/2023, 5:23 PM// Import articles
$connection
->table('articles', 's')
->orderBy('s.id')
->chunk(1000, function ($articles) {
foreach ($articles as $oldarticle) {
// dd($oldarticle);
$oldarticle = (array)$oldarticle;
$article = new Article();
$article->id = $oldarticle['id'];
$article->created_at = $oldarticle['created_at'];
$article->updated_at = $oldarticle['updated_at'];
$article->published = $oldarticle['published'];
try {
$article->save();
} catch (QueryException) {
echo "article " . $article->id . " could not be saved" . PHP_EOL;
}
}
});`
I tried something like this as mentioned in Translatable but it doesn't work.
$data = [
'id' => $oldartist['id'],
'first_name' => $oldartist['first_name'],
'last_name' => $oldartist['last_name'],
'en' => ['text' => 'My first post'],
'fr' => ['text' => 'Mon premier post'],
];
$artist = Post::create($data);
Thanks for your help