我有一张运动队的桌子。记录显示团队选择和其他一些信息。我想用团队选择更新记录。我的模型是这样的:使用Laravel模型的更新表格
class Selection extends Model {
protected $table = "selection";
protected $fillable = [
'loose',
'hooker',
'tight',
'secrow1',
'secrow2',
'blindflank',
'openflank',
'eight',
'scrum',
'fly',
'leftwing',
'rightwing',
'fullback',
'sub1',
'sub2',
'sub3',
'sub4',
'sub5'
];
}
所以我有一个形式,给出了位置的所有数据,并给出了ID在数据库中记录。在我的控制,我有:
public function storeFirstTeam()
{
$input = Request::all();
Selection::update($input->id,$input);
return redirect('first-team');
}
,但我得到了以下错误:
Non-static method Illuminate\Database\Eloquent\Model::update() should not be called statically, assuming $this from incompatible context
任何人都可以指出我的傻错误?
您必须先选择要更新的行。当您发布更新请求时,如何获得选择的“id”? –
尝试像这样:'Selection :: whereId($ id) - > update($ request-> except(['_ method','_ token']));' –