messi89's avatar

massive insertion with Laravel

Hi guys;

I want to insert an array of data to my datatable

my $dataArray looks like :

array(2) {
[0] array(6) {
["destinataire"] "*"
["message"] "*****"
["user_id"] "***"
}
[1] array(6) {
["destinataire"] "*"
["message"] "******"
["user_id"] "*"
}
}

I try to use :

Message::create($dataArray);

but no insertion !!! if I do the insertion with foreach it's work !

any idea to do massive insertion without foreach (with eloquent or fluent)

thanks

0 likes
2 replies
thepsion5's avatar
Level 25

You should be able to use Message::insert($dataArray);

messi89's avatar

Thanks @thepsion5 , I think its ok now

but how can I get the ids of the last insertion ?

Please or to participate in this conversation.