2017-05-14 59 views
1

我創建了一個網頁,更新數據庫中的一些數據:更新Laravel一些數據庫行

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) 

出了什麼問題?

回答

0

您在表單輸入中包含csrf標記,因此將_token字段添加到請求中。你可以把只有某些字段從類似請求:

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

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

我得到這個錯誤時使用此代碼 BadMethodCallException在Builder.php線2345: 調用未定義的方法照亮\數據庫\查詢\生成器:: ()() –

+0

@Sina Maafi你有什麼要求的領域? –

+0

@SinaMaafi我已經更新了我的答案,請再次檢查 –