I have the following query that is working but I'm wondering what the Eloquent ORM equivalent would be?
DB::table('exercises')->whereIn('id', $ids)->update($request->all());
Thanks
$update = ItemTable::where('item_type_id', '=', 1); $update->colour = 'black'; $update->save();
$where['page_id'] = [1,2,3]; $update = [['column' => 'value1'],['column' => 'value2']]; DB::table('my_table')->where($where)->update($update);
We can update the records using the DB facade with update method. The syntax of update method is as shown in the following table. Run an update statement against the database.
Eloquent is an ORM, which means can automatically handle the relationships of your models for you. You can retrieve related models without writing complex queries. You can even retrieve database information without any kind of database knowledge at all.
Eloquent equivalent is almost the same:
Exercise::whereIn('id', $ids)->update($request->all());
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With