Riaan
Riaan

Reputation: 195

NotFoundHttpException in RouteCollection Laravel 5.2

So I have these routes defined in my routes.php:

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

The first two works fine. But for some reason the third one [ /verify/{$key} ] throws a NotFoundHttpException.

The verify route calls the Verify() function in my AuthController as shown below.

 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');
    }

When calling the php artisan route:list from the terminal the verify/{key} shows up.

Any help would be much appreciated.

Upvotes: 0

Views: 77

Answers (1)

Jilson Thomas
Jilson Thomas

Reputation: 7313

Change this:

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

to

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

You don't have to add $ along with the variable in the route.

Upvotes: 1

Related Questions