【发布时间】:2020-05-06 14:57:39
【问题描述】:
我发送一封电子邮件进行验证,它给了我这个错误。
Too few arguments to function App\Http\Controllers\MainController::sendEmailDoneR(), 2 passed and exactly 3 expected
这是我的 sendEmailDoneR 代码。
function sendEmailDoneR($verifytoken, $rvid, $tischid){
$verifytokenc=DB::table('reservierung')->select('verify_token')->where('rvid', ''.$rvid.'')->value('verify_token');
if($verifytoken==$verifytokenc){
$this->setverifiedR($rvid, $tischid);
}
else{
//mit error zurückgeben
return view('verificationfailed');
}
}
这是我的 web.php。
Route::get('verifyr/{email}/{verify_token}', 'MainController@sendEmailDoneR')->name('sendEmailDoneR');
这是我的电子邮件视图。
<p>Just one more step until you can start creating a profile for your restaurant!</p>
<p>Please verify your E-Mail by </p><a href="{{route('sendEmailDoneR', ["verifytoken"=>$verifytoken, "rvid"=>$rvid, "tischid"=>$tischid])}}">clicking here</a>
我可以访问电子邮件中的变量已经尝试过了!
【问题讨论】:
-
'verifyr/{email}/{verify_token}'应该匹配($verifytoken, $rvid, $tischid)。路由文件中{}中的任何内容都是 URL 参数,并被传递给函数。{}中只有 2 个值,但函数声明中有 3 个参数。其中一个是错误的,所以修复它:) -
旁注,您不需要
where('rvid', ''.$rvid.'')上的引号/连接。只要通过$rvid,它就可以正常工作了。 -
@TimLewis 谢谢我想通了。我不得不在我的 web.php 中再添加一个值。