Have a problem regards to validating values from looping. I get the values 'mobile_no' and 'email' from the loop to validate if those values are existing in my other table with the column of mobile no and email. Thankyou for any help.
$get_values = DB::table('users_preview')->get();
foreach($get_values as $values){
$email = $values->email;
$mobile_no = $values->email;
/* now I want to validate if values of email and mobile no exist in
user's table , this is my sample way to do it which is actually
wrong*/
// it only shows one validations but i like to show every each validations
for rows
if (users_preview::where('mobile', '=', $mobile_no)->count() > 0) {
return response()->json([
'message' => 'mobile is already
exist',
'errors' => $numbers,
'status' => false
]);
}
}
//scripts are
<script>
if(data.status == false){
//some codes
}
</script>