Level 3
Why don't you just make the "role_val" field nullable in the database and only send the value if the condition is true?
1 like
if($request->sys_status == 4){
$sys_statu = 4;
$role_val == NULL;
}else{
$sys_statu = $request->sys_status;
$role_val = $request->role;
}
Your code could be just like this
$sys_statu = $request->sys_status;
$role_val = $sys_statu == 4 ? null : $request->role;
Please or to participate in this conversation.