我想使用 fill 将数据保存在数据库中,但出现错误
I want to save data in DB using fill but I get an error
我想读取并覆盖现有数据
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();
感谢合作
填充成功后全部使用
$param->fill($request->all())->save();
我想读取并覆盖现有数据
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();
感谢合作
填充成功后全部使用
$param->fill($request->all())->save();