In laravel controller function the coding has make changes and save it,when i refresh the webpage the coding is not reflected?
Actually code:-
public function generate(Request $request)
{ # Validate Data $request->validate
([ 'reset_mailid' => 'required|exists:vs360_tables,mailid' ]);
# Generate An OTP
// Create a new instance of the Request class
$request = $request->input('reset_mailid');
// Call the generateOtp() method with the correct argument type
$verificationCode = $this->generateOtp($request);
$message = "Your OTP To Login is :- ".$verificationCode->otp;
# Return With OTP
return redirect()->route('otp.verification', ['reset_mailid' => $verificationCode->reset_mailid])->with('success', $message);
}
public function generateOtp(Request $request)
{
$user = User::where('mailid', $request)->first();
# User Does not Have Any Existing OTP
$verificationCode = VerificationCode::where('reset_mailid', $user->reset_mailid)->latest()->first();
$now = Carbon::now();
if($verificationCode && $now->isBefore($verificationCode->expire_at)){
return $verificationCode;
}
// Create a New OTP
return VerificationCode::create([
'reset_mailid' => $request->input('reset_mailid'),
'otp' => rand(123456, 999999),
'expire_at' => Carbon::now()->addMinutes(10)
]);
}
AppHttpControllersAuthOtpController::generateOtp(): Argument #1 ($request) must be of type IlluminateHttpRequest, string given, called in D:localserverhtdocsLaravel_Projectsfinal_vserve360appHttpControllersAuthOtpController.php on line 32
2
Answers
i change the code in controller function as you say but the coding is not reflected in webpage when i refresh?
You have a problem in your generate method, what your are doing actually is replacing the laravel request object inot reset_mailid, so the request variable has a string now, change your code like this:
In the second function you dont need http request, just receive the parameter in any name, change the code like below:
IT should work now