This is my simple code but not getting an idea of how I send and validate OTP on user email actually, I am new to Laravel and developing the backend for a project I am now stuck on send OTP kindly help me out
public function sendOTP(Request $request){
$otp = rand(10000,99999);
$std = Student::where('email','=',$request->email)->update(['otp' => $otp]);
if ($std == true) {
return response([
"code" => 200,
"message" => "OTP send Successfully",
"object" => $std
]);
} else {
return response([
"code" => 400,
"message" => "Email Not Exist"
]);
}
My api.php route
Route::post('sendOTP',[StudentController::class,'sendOTP']);