2016-03-03 95 views
0

所以我在我的routes.php文件定義了這些路線:NotFoundHttpException在RouteCollection Laravel 5.2

Route::post('/register', 'Auth\[email protected]'); 
Route::post('/login', 'Auth\[email protected]'); 
Route::get('/verify/{$key}', 'Auth\[email protected]'); 

的前兩部作品的罰款。但出於某種原因,第三個[/ verify/{$ key}]會拋出一個NotFoundHttpException異常。

驗證路由在我的AuthController中調用Verify()函數,如下所示。

public function Verify($key) 
    { 
     $user = User::Where('verification_code', $key); 

     if(!$user) 
     { 
      flash()->error('Error Occurred in verification.'); 
      return redirect('/login'); 
     } 

     $user->verified = 1; 
     $user->verification_code = null; 
     $user->save; 

     flash()->success('Account Successfully Verified.'); 
     return redirect('/login'); 
    } 

當從終端調用php artisan route:list時,出現verify/{key}。

任何幫助將不勝感激。

+1

這是一個'GET'或'POST'請求​​嗎? –

+0

GET,我用鏈接向用戶發送驗證郵件,例如:www.example.com/verify/key_here – Riaan

回答

1

更改此:

Route::get('/verify/{$key}', 'Auth\[email protected]');

Route::get('/verify/{key}', 'Auth\[email protected]'); 

您不必添加$與路由中的變量一起。

+0

啊這麼小的一個錯誤:D,非常感謝。 – Riaan

相關問題