我的更新方法在localhost中工作,但在服务器上遇到406错误,我尝试了.htaccess方法,但是它无法正常工作。
我发现并非所有数据都无法更新,只有部分数据返回406错误。
这是我的代码:
public function update(UpdateUserRequest $request, $id)
{
//
$user = User::findOrFail($id);
$user_detail = [];
if($user->id != Auth::user()->id && $user->role_id != 1 && $user->role_id != 2) {
$user_detail = [
'surname' => $request->surname ,
'givenname' => $request->givenname ,
'gender' => $request->gender ,
'birthday' => $request->birthday ,
'ic_no' => $request->ic_no ,
'address' => $request->address ,
'bank_acc_no' => $request->bank_acc_no ,
'bank_name' => $request->bank_name ,
'role_id' => $request->role
];
}
else if ($user->id == Auth::user()->id) {
$user_detail = [
'surname' => $request->surname ,
'givenname' => $request->givenname ,
'gender' => $request->gender ,
'birthday' => $request->birthday ,
'ic_no' => $request->ic_no ,
'address' => $request->address ,
'bank_acc_no' => $request->bank_acc_no ,
'bank_name' => $request->bank_name
];
}
$user->update($user_detail);
...
Session::flash('success_message', trans('text.text_user_detail_update_sucessfully'));
return redirect()->back();
}
我还发现即使我评论Update方法中的所有代码,浏览器仍然会给我406错误。
任何人都知道如何修复它?