Closed rogierborst closed 11 years ago
To my previous answer: there's actually a ready-to-use solution available (MySQL): https://github.com/kfirba/import-query-generator
@cabloo Looks like this is one of the best solutions we got :) I mean we need to Transform our data to collection and then save them, so :)
This worked really well for me, I read multiple records from the cart table and save them into sells table ...
$carts = cart::all(); foreach($carts as $cart){ $sell = new sell; $sell->product_id = $cart->product_id; $sell->quantity = $cart->quantity; $sell->total = $cart->total; $sell->user_id = $cart->user_id;
$sell->save();
}
This worked for me, so i guess i would like to share it with you guys - https://stackoverflow.com/questions/54435692/how-to-save-many-records-in-a-table-laravel-eloquent-no-relationship/54436120
I'm locking this to prevent this from becoming a forum thread and because the issue is so old.
I'd love to be able to insert multiple records into the database in one fell swoop. I know you can do that with something like
User::insert([array of multiple user detail arrays]);
butinsert
is not handled by Eloquent, but by Fluent instead.One of the disadvantages of that, is that Fluent doesn't set timestamps on these records.