Q:

How to use variables in routes in laravel?

I'm trying to build a application in laravel 5.3 in which I get the variable from request method and then trying to pass that variable in a redirect to the routes. I want to use this variable in my view so that I can be able to display the value of variable. I'm currently doing this:
In my controller I'm getting the request like this:
public function register(Request $request)
{
    $data = request->only('xyz','abc');
    // Do some coding
    .
    .
    $member['xyz'] = $data['xyz'];
    $member['abc'] = $data['abc'];
    return redirect('member/memberinfo')->with('member' => $member);
}

Now I've following in my routes:
Route::get('/member/memberinfo', 'MemberController@memberinfo')->with('member', $member);

Now in MemberController I want to use $member variable and display this into my view:
public function memberinfo()
{
  return view('member.memberinfo', ['member' => $member]);
}

But I'm getting an error in the routes files 

Call to undefined method Illuminate\Routing\Route::with()

Help me out, how can I achieve this.

A:

When you're using redirect()->with(), you're saving data to the session. So to get data from the session in controller or even view you can use session() helper:
$member = session('member'); // In controller.

{{ session('member')['xyz'] }} // In view.

Alternatively, you could pass variables as string parameters.
Redirect:
return redirect('member/memberinfo/xyz/abc')

Route:
Route::get('/member/memberinfo/{xyz}/{abc}', 'MemberController@memberinfo');

Controller:
public function memberinfo($xyz, $abc)
{
    return view('member.memberinfo', compact('xyz', 'abc'));
}

