RouteCollection 中的 NotFoundHttpException Laravel 5.2
NotFoundHttpException in RouteCollection Laravel 5.2
所以我在 routes.php:
中定义了这些路线
Route::post('/register', 'Auth\AuthController@Register');
Route::post('/login', 'Auth\AuthController@Login');
Route::get('/verify/{$key}', 'Auth\AuthController@Verify');
前两个工作正常。但出于某种原因,第三个 [ /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 时,验证/{key} 出现。
如有任何帮助,我们将不胜感激。
改变这个:
Route::get('/verify/{$key}', 'Auth\AuthController@Verify');
到
Route::get('/verify/{key}', 'Auth\AuthController@Verify');
您不必在路由中添加 $
和变量。
所以我在 routes.php:
中定义了这些路线Route::post('/register', 'Auth\AuthController@Register');
Route::post('/login', 'Auth\AuthController@Login');
Route::get('/verify/{$key}', 'Auth\AuthController@Verify');
前两个工作正常。但出于某种原因,第三个 [ /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 时,验证/{key} 出现。
如有任何帮助,我们将不胜感激。
改变这个:
Route::get('/verify/{$key}', 'Auth\AuthController@Verify');
到
Route::get('/verify/{key}', 'Auth\AuthController@Verify');
您不必在路由中添加 $
和变量。