Thursday, March 9, 2017

Passing parameter while redirecting to another route

I am trying to 'redirect to' from one controller method to another through the route. However, I want to pass some data as well. I tried Session::get('name') but doesn't seem to work. This is what I tried:

public function before() {
   return Redirect::to('later')->with('x', 'y');
}

public function later() {
   dd( Session::get('x') ); // null
   dd( $x ) // not working
}

My route is like classic:

Route::get('/later', 'TheController@later')->middleware('auth');

What am I missing?



via senty

Advertisement