2016-03-03 100 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

相关问题