php - How to get retuned value from one laravel route into another route -


how value of 1 route another

route::get('/first_url', function () {    return "hello test"; }); 

i tried not worked.

route::get('/second_url', function () {    $other_view = redirect::to('first_url'); }); 

i want returned value first_url variable $other_view in second_url process , manipulate returned value.

using redirect changing url. dont want use.

any idea ??? or trying wrong thing do.

if want return first_url, this:

route::get('/first_url', ['as' => 'firstroute', function () {     return "hello test"; }]);  route::get('/second_url', function () {     return redirect()->route('firstroute'); }); 

learn more redirects routes here.

update:

if want pass variable, can use form or create link parameters. can try {{ route('second_url', ['param' => 1]) }}

then second route this:

route::get('/second_url/{param}', ['uses' => 'mycontroller@mymethod', 'param' => 'param']); 

and mymethod method in mycontroller:

public function mymethod($param){     echo $param; ... 

Comments