1ModelName::whereId($id)->update($request->all());
1$post = Post::find(3);
2$post->title = "Updated title";
3$post->save();
4
5
6or
7
8
9 $affectedRows = Post::where("id", 3)->update(["title" => "Updated title"]);
10
1$flight = App\Models\Flight::find(1);
2
3$flight->name = 'New Flight Name';
4
5$flight->save();
1// Eloquent's Model::query() returns the query builder
2
3Model::where()->get();
4// Is the same as
5Model::query()->where()->get();
6
7Model::query();
8// Can be useful to add query conditions based on certain requirements
9
10// See https://stackoverflow.com/questions/51517203/what-is-the-meaning-of-eloquents-modelquery
1Post::where('id',3)->update(['title'=>'Updated title']);
2