Laravel更新了一些数据库行

时间:2017-05-14 18:33:04

标签: laravel-5

我创建了一个更新数据库中某些数据的页面:

    public function postedit(Requests\editRequest $request)
{
    $upgrade = DB::table('upgrade')->where('user_id', Auth::user()->id)->update($request->all());


}

当我填写表格时,我收到此错误:

QueryException in Connection.php line 725:
SQLSTATE[42S22]: Column not found: 1054 Unknown column '_token' in 'field 
list' (SQL: update `upgrade` set `_token` = 
g6MudghCdVvtL0ir361h9ysx53gRnv227LKSSZIz, `tell` = 867136819, `mobile` = 
316136135, `Address` = usa-ny, `zip_code` = 141515 where `user_id` = 
19)

问题是什么?

1 个答案:

答案 0 :(得分:0)

您在表单输入中包含csrf标记,因此_token字段将添加到请求中。您可以从请求中选择 某些字段,如:

$input = Request::only('tell',
'mobile',
'Address',
'zip_code');

$upgrade = DB::table('upgrade')->where('user_id', Auth::user()->id)->update($input);