@marymvlg28 Maybe try:
foreach ($data as $id => $status) {
MyModel::where('id', $id)->update('status_id', $status);
}
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hi,
I'm wondering if there is a way to execute a bulk update like this:
$data = [ ["id" => 20, "status_id" => 1], ["id" => 21, "status_id" => 2], ["id" => 23, "status_id" => 3] ];
MyModel::update($data);
Where id = 20 set status_id = 1... and so on...
EDIT: If I had 1000 rows to update, I would have to do 1000 connections to the database, and that is just what I want to avoid, Codeigniter has a way to update multiple data in a single connection, which is much faster. I need to know if there is a way to do that in Laravel.
Please or to participate in this conversation.