https://twill.io logo
Hello, I'm tring to import an Old DB to Twill, I'm...
# ❓questions
c
Hello, I'm tring to import an Old DB to Twill, I'm actually using seeder for this, it works pretty well for the "main table" but how can I save the content to the Translations & Slugs tables also ? My code actually looks like this.
Copy code
// 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.
Copy code
$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