Laravel eloquent update record without loading from database

Dester Dezzods picture Dester Dezzods · Apr 12, 2015 · Viewed 131.4k times · Source

I'm quite new to laravel and I'm trying to update a record from form's input. However I see that to update the record, first you need to fetch the record from database. Isn't is possible to something like to update a record (primary key is set):

$post = new Post();
$post->id = 3; //already exists in database.
$post->title = "Updated title";
$post->save();

Answer

KaJasB picture KaJasB · Feb 26, 2016
Post::where('id',3)->update(['title'=>'Updated title']);