我想读取和覆盖现有数据
ProjectController.php
public function update(Request $request,$id)
{
$param = Project::find($id);
$param = fill($request)->save();
return redirect('/project');
}
我收到此错误,无法使用填充
Call to undefined function App\Http\Controllers\fill()
我尝试了
$param = Project::fill($request)->save();
但是我遇到了这个错误
Non-static method Illuminate\Database\Eloquent\Model::fill() should not be called statically
这也是
public function update(Request $request,$id)
{
$param = Project::find($id);
$param->fill($request)->save();
return redirect('/project');
}
就是这样
Argument 1 passed to Illuminate\Database\Eloquent\Model::fill() must be of the type array, object given, called in
添加所有()后效果很好
$param->fill($request->all())->save();
感谢您的合作
答案 0 :(得分:0)
在填充成功后使用所有内容
$param->fill($request->all())->save();