【问题标题】:NotFoundHttpException in RouteCollection Laravel 5.2RouteCollection Laravel 5.2 中的 NotFoundHttpException
【发布时间】:2016-06-17 04:46:52
【问题描述】:

所以我在我的 routes.php 中定义了这些路由:

Route::post('/register', 'Auth\AuthController@Register');
Route::post('/login', 'Auth\AuthController@Login');
Route::get('/verify/{$key}', 'Auth\AuthController@Verify');

前两个工作正常。但是由于某种原因,第三个 [ /verify/{$key} ] 抛出了 NotFoundHttpException。

verify 路由调用我的 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} 会出现。

任何帮助将不胜感激。

【问题讨论】:

  • 这是GETPOST 请求吗?
  • GET,我给用户发送一封验证邮件,里面有一个链接,例如:www.example.com/verify/key_here

标签: php laravel laravel-5.2


【解决方案1】:

改变这个:

Route::get('/verify/{$key}', 'Auth\AuthController@Verify');

Route::get('/verify/{key}', 'Auth\AuthController@Verify');

您不必将$ 与路径中的变量一起添加。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-07-24
    • 1970-01-01
    • 1970-01-01
    • 2017-09-05
    • 2016-07-01
    • 2016-11-10
    相关资源
    最近更新 更多