lundi 25 janvier 2016

How to use intented function in Laravel

I need to register in a tournament with the URL:

http://ift.tt/1Pywu0M

This URL is in the middleware 'auth', so if the user is not logged, he is redirected to login / page.

What I need is to redirect to

http://ift.tt/1Pywu0M

After login.

In my routes.php, I have:

Route::get('tournaments/{tournamentId}/register', 'TournamentController@register');

I was told to use

redirect()->intended

but I don't know how to do it.

In the general case, User will be redirected to /admin, but in this case, I want him to keep doing his main action ( Register tournament)...

I'm using the built in trait for login, so I checked what system do when login and it is already using this function:

protected function handleUserWasAuthenticated(Request $request, $throttles)
{
    if ($throttles) {
        $this->clearLoginAttempts($request);
    }

    if (method_exists($this, 'authenticated')) {
        return $this->authenticated($request, Auth::guard($this->getGuard())->user());
    }

    return redirect()->intended($this->redirectPath());
}

Thing is it will redirect me to a default path, not a dynamic one...



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire