$post = Post::find(3);
$post->title = "Updated title";
$post->save();
or
$affectedRows = Post::where("id", 3)->update(["title" => "Updated title"]);
Model::where('id',1)->update(['name'=>'updated name']);
//or
$data = Model::findOrFail($id); //primary id
$data->name = $request->input('updated name');
$data->save();
public function update(Request $request, Teacher $teacher)
{
$teachers = $request->all();
$teacher->save();
return back()->with('message', 'Record Successfully Updated!');
}
Post::where('id',3)->update(['title'=>'Updated title']);
public function update(Request $request, Teacher $teacher)
{
$input = $request->all();
$teacher->fill($input)->save();
return back()->with('message', 'Record Successfully Updated!');
}
ModelName::whereId($id)->update($request->all());
public function update(Request $request, $id)
{
$supplier = SupplierModel::findOrFail($id);
$supplier->update($request->all());
return redirect(route('admin.suppliers.index'))->with('message', 'Поставщик успешно обновлен');
}
User::query()->whereId($user->id)
->update([
'column' => 'value',
'n' => 'n',
]);
$flight = AppModelsFlight::find(1);
$flight->name = 'New Flight Name';
$flight->save();
<form action="{{route('blog.update',$blog[0]->id)}}" method="post">
@csrf
@method('PUT')
<textarea name="txtTitle" >
{{$blog[0]->title}}
</textarea>
<input type="submit" value="Update" />
</form>