I'm trying to update a value in my database with a new value base on user input but I can't seem to make it work.
This is the code that successfully manually updates all the rows I want
public function updateno(Request $request){
if(Auth::id()){
$user_id=Auth::id();
$data = details::where('user_id', $user_id)
->where('order','pending')
->update(['contactno' => 111111]);
return redirect()->back();
}else{
return redirect('/login');
}
}
The result
id | user_id | name | status | order | contactno | address |
---|---|---|---|---|---|---|
1 | 13 | John | pending | Burger | 111111 | Sta Maria |
2 | 13 | John | pending | Latte | 111111 | Sta Maria |
3 | 12 | Mikael | approved | Burger | 233333 | San Fernando |
4 | 13 | John | pending | Coke | 111111 | Sta Maria |
but when I try the $request for new user input or when they update their contact no. like the code below, it instead saves a random number 2147483647
which is completely different from the user input 8917772
I also tried dd($request->contactno)
to see if the user input does retrieve it correctly and it does. That's why it makes me confused and don't know the problem or to fix it.
public function updateno(Request $request){
if(Auth::id()){
$user_id=Auth::id();
$data = details::where('user_id', $user_id)
->where('order','pending')
->update(['contactno' => $request->contactno]);
return redirect()->back();
}else{
return redirect('/login');
}
}
The result is like this instead of the user input 8917772
id | user_id | name | status | order | contactno | address |
---|---|---|---|---|---|---|
1 | 13 | John | pending | Burger | 2147483647 | Sta Maria |
2 | 13 | John | pending | Latte | 2147483647 | Sta Maria |
3 | 12 | Mikael | approved | Burger | 233333 | San Fernando |
4 | 13 | John | pending | Coke | 2147483647 | Sta Maria |
CodePudding user response:
maybe you need to change the type of the field "contactno" to BIGINT (20)
or something else, so the field can store values.