spatie / laravel-translatable

Making Eloquent models translatable

Home Page:https://spatie.be/docs/laravel-translatable

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Eloquent Mass creation

JoNMii opened this issue · comments

Im adding a Seeder to my project wich will add a country list.

I tried doing this way but it fails:

        $objetosEloquent = array();

        foreach($countries as $country)
        {
            $item = \App\Models\Country::create([
                'code' => $country["code"],
            ]);
            $item->setTranslation('name', 'EN', $country["name"]);
            array_push($objetosEloquent, $item);
       }
        \DB::table('countries')->insert($objetosEloquent);

However adding them 1 by 1 using save() works.

Thanks!