Friday, March 31, 2017

L5.3 - Call route from another route

I've a simple route into the file web.php:

Route::get('first/{param?}', [
   'uses' => 'App\Http\Controllers\MyController@index',
   'as' => 'myControllerIndex'
]);

Now, I'd like to create a second route that uses the first route but passing specific params. I tried something like this:

Route::get('second', function () {
   return file_get_contents(route('myControllerIndex', ['param' => 'book1']));
});

but it doesn't work.

Can anyone help me?

Thank you.



via vlauciani

Advertisement