2016-03-07 45 views
1

我試圖構建一個應用程序,強制用戶在註冊時確認其電子郵件地址。我發送一封包含這樣一個鏈接:使用路由參數時未找到控制器方法

http://localhost:8000/verifieren/TOKEN&user=USERNAME 

現在,當我嘗試訪問此鏈接,下面的錯誤彈出我的屏幕上:

NotFoundHttpException in Controller.php line 91: 
Controller method not found. 

從堆棧跟蹤,我得到了以下

at Controller->missingMethod(array('verifieren', 'GILDE-jOWPBRhcOW1fUFg77xnb0kgM22CUm4&user=Wesley')) 

我認爲它的意思是,它試圖調用verifieren的方法?

這是我使用的路線:

Route::get('/verifieren/{{ confirmation_code }}&user={{ username }}', 'Authentication\[email protected]'); 

而且這條路線對應於以下方法:

public function mailConfirmation($code, $username) { 
     $user = User::where(["confirmation_code" => $code, "username" => $username])->first(); 

     $user->active = '1'; 
     $user->confirmation_code = null; 
     $user->active_date = date('Y-m-d'); 
     $user->save(); 

     return redirect('/welkom')->with("flash_notice", "account_succesfully_activated"); 
} 

我絕對不知道爲什麼會發生這種事。我認爲這可能是其他路線干擾,但事實並非如此。

對我來說,這是一個相當新的東西,所以我可以想象,我在代碼中犯了一個菜鳥錯誤。

在此先感謝。

回答

1

方法名稱在路由和控制中存在拼寫錯誤LER方法名

在你的路線,你有方法的名稱作爲

@mailConformation 

但在你的控制你的方法名是

mailConfirmation($code,$username) 

所以,糾正你的方法名的拼寫中的路由作爲:

Route::get('/verifieren/{{ confirmation_code }}&user={{ username }}', 'Authentication\[email protected]'); 
+0

事實上,我沒有發現,讓我傷心,謝謝! –

+0

@WesleyPeeters有時候會發生.. :) – Drudge

0

變化

http://localhost:8000/verifieren/TOKEN&user=USERNAME 

http://localhost:8000/verifieren/TOKEN?user=USERNAME 

您正在起訴&的呢?

而且路線中的方法名稱爲 「mailConformation」,並在控制器的方法名是 「mailConfirmation」

變化

'Authentication\[email protected]' 

'Authentication\[email protected]' 

在您的路線

相關問題