I have a function that is taking an id as a param, and updates the db using the DB method. however, when i run the code, the variable is not being passed to the method. to test, i replaced $id with an integer and it worked, so i think the DB method can not access the variable from the parameter
public function disable($id)
{
// Update the user status to 0 from 1
DB::table('employees')->where('id', $id)->update(['status' => 0]);
return redirect('/employee')->with('error', 'User is disabled, all related accounts are now shutdown!...');
}
Update: Forgot to mention that i have already checked, and the param comes inside the function OK, i can return the id outside of the method
SOLUTION As shown in the comment, the varDump was returning "id=9" where i need "9", i noticed in the form piece of my code, there was an extra "id=" before the id which caused a malfunction.
$idparameter is a string, so mysql is failed to match the id, convert it in an integer as$id=(int)$id;, then trydd($id);in this function to check if$idis passed true