I want to pass the $new_token
variable from verified function in app to the verify function in controller. but I dont know how.
My Controller:
public function verify($token)
{
User::where('email_token',$token)->firstOrFail()->verified();
// I want to bring back variable $new_token from verified function
$email = new EmailAdmVerification(new User(['email_token' => $new_token,
'name' => $user->name]));
return redirect('login');
}
My App
public function verified()
{
$new_token = str_random(10);
$this->email_token = $new_token;
$this->save();
}
Thanks you very much for any help or feedback
Just return it from your function:
public function verified()
{
$new_token = str_random(10);
$this->email_token = $new_token;
$this->save();
return $new_token; // <----
}
Now that this method returns your desired value, you can retrieve it wherever you need it:
public function verify($token)
{
$new_token = User::where('email_token',$token)->firstOrFail()->verified(); // <--
$email = new EmailAdmVerification(new User(['email_token' => $new_token,
'name' => $user->name]));
return redirect('login');
}