这是我得到的错误:“ SQLSTATE [23000]:违反完整性约束:1048 Le champ'username'ne peutêtrevide(null)(SQL:update user
set username
=吗? ,pseudo
=?,email
=?,password
=?,其中id
= 29)“
public function updateUser($id, Request $request)
{
if ($id != NULL) {
$username = $request->get('username');
$pseudo = $request->get('pseudo');
$email = $request->get('email');
$password = $request->get('password');
$retour = testToken();
if($retour == TRUE) {
$data = User::where('id', $id)->update(array('username'=>$username, 'pseudo'=>$pseudo, 'email'=>$email, 'password'=>$password));
return response()->json([
'message'=>'OK',
'data'=>$data]
,200);
} else {
return response()->json([
'message'=>'Forbidden',
]
,403);
}
} else {
return response()->json([
'message'=>'Not found',
]
,404);
}
}
答案 0 :(得分:0)
好吧,答案就是通过这种方式获取参数:
$username = Input::get('username');
$pseudo = Input::get('pseudo');
$email = Input::get('email');
$password = Input::get('password');