I am trying to do exactly the same in Laravel 8. I would like to have two different pages that are configured in the routes file to display/act differently based on parameters to the controller function.
The defaults() method is also in Laravel 8, but as a warning to anyone trying to use it, it does not work as expected.
It ignores the parameter name and looks only at the parameter order. So, you have to call defaults() in the order of the function/method parameters. Not sure if this is a bug in Laravel 8. If I am using it wrong, let me know.
For example: I can do this:
Route::get('/displayone', [WAYFController::class, 'wayf'] )
->middleware('not-auth')
// These must be in order and name of parameter doesn't matter??!!
->defaults('tiledUI', true)
->defaults('showAffiliateLogin', false)
->defaults('type', 'full')
->defaults('tiledUIConfigCode', 'online'); // required for Tiled UI
Route::get('/displaytwo', [WAYFController::class, 'wayf'] )
->middleware('not-auth')
// These must be in order and name of parameter doesn't matter??!!
->defaults('tiledUI', false)
->defaults('showAffiliateLogin', false)
->defaults('type', 'full')
->defaults('tiledUIConfigCode', 'none'); // required for Tiled UI
This works if that's the order of the function parameters. However, if I switch the order of the calls to defaults(), it will pass the values to the wrong parameters. The parameter names such as 'tiledUIConfigCode' have no effect.