문제

I have validated and authenticated a user and upon authentication I redirect him to the 'dashboard view file'.

What I want know is how do I send that user's data along with the redirected command.

My function looks like this:

if($validator->passes()) {
/-- validate user --/
return Redirect::to('users/login')->with('message', 'Thanks for registering!');

I would appreciate it if someone helped me add the user's data.
Thanks

도움이 되었습니까?

해결책

You can pass it:

$user = User::find(1);

return Redirect::to('users/login')
       ->withMessage('Thanks for registering!');
       ->withUser($user);

And get it in your controller

$user = Session::get('user');

Or you could just pass the id

return Redirect::to('users/login')
       ->with('message', 'Thanks for registering!');
       ->with('user_id', $user->id);

And search for it again

$user = User::find(Session::get('user_id'));
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top