如何使用
request->all()
更新所有记录,我有许多列要更新。下面是我的创建方法代码,我用它来插入多个新记录,这很好用。public function store(Request $request)
{
$teacher = new Teacher;
$teacher::create($request->all());
$teacher->save();
return back()->with('message','Teacher Added Successfully!');
}
这是我尝试过但没有成功的内容:
public function update(Request $request, Teacher $teacher)
{
$teachers=$request->all();
$teacher->save();
return back()->with('message','Record Successfully Updated!');
}
$request->all()
也获取键/值数组。 - Inzamam Idrees