VerifyController.php
verifyUser
verifyUserpublic function verifyUser(Request $request)
{
// Extract the verification code from the request
$verificationCode = $request->input('verificationCode');
// Search for a user with the provided verification code in the UserAccount model
$user = UserAccount::where('verification_code', $verificationCode)->first();
// Check if a user with the given verification code is found
if (isset($user)) {
// If found, set the 'verified' attribute to true and save the user
$user->verified = true;
$user->save();
// Prepare a success response
$response = [
'SUCCESS' => 1,
];
// Return the success response
return $response;
} else {
// If no user is found with the given verification code, prepare a failure response
$response = [
'SUCCESS' => 0,
];
// Return the failure response
return $response;
}
}Last updated