我想将$new_token
变量从应用程序中的验证函数传递到控制器中的验证函数。但我不知道如何。
我的控制器:
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');
}
我的应用
public function verified()
{
$new_token = str_random(10);
$this->email_token = $new_token;
$this->save();
}
非常感谢您的帮助或反馈
答案 0 :(得分:0)
只需从您的函数中将其返回:
function Factory(string) {
var variables = {foo: 'bar'};
console.log(string + " is equal to " + variables[string])
}
现在该方法返回您想要的值,您可以在需要的任何地方检索它:
public function verified()
{
$new_token = str_random(10);
$this->email_token = $new_token;
$this->save();
return $new_token; // <----
}