I have this route.php:
Route::group(['prefix' => 'v3/page1'], function()
{
Route::get('page1', 'TestController@page1');
});
Route::group(['prefix' => 'v4/page1'], function()
{
Route::get('page1', 'TestController@page1');
});
As you can see, there are 2 groups that have the same routes. The only difference is that the prefix is slightly different for each group.
I need a way to pass data from route to controller. In this case Im only interested in passing the "v3" or "v4"-string from route to controller.
I have read a little about before_filter. But Im not sure if it is the right way to go. I can imagine that a solution could be to extract the url (maybe in the constructor for the controller) and from there understand if the prefix is v3 or v4. But I wonder if there is a better way, more a best practice. Maybe something with before_filter?