Loading…

How to use update query in Laravel?

With the help of update() function, we can update our data in the database according to the condition.

Example

                                        

Blog::where(['id' => $id])->update([
   'title' => ’Best Interview Questions’,
   ‘content’ => ’Best Interview Questions’
]);

OR

DB::table("blogs")->where(['id' => $id])->update([
    'title' => ’Best Interview Questions’,
    ‘content’ => ’Best Interview Questions’
]);

Suggest An Answer

No suggestions avaliable!

Latest post from Laravel Interview Questions

Ask Question