The query string is considered part of the inputs and not part of the URI for routing. If you want the 'id' part of the URI to be optional you would have to adjust your definition. Then in your controller you can access your reference
query string parameter.
Route::get('user/{id?}', 'UserController@index')->name('user');
public function index(Request $request, $id = null)
{
$reference = $request->input('reference');
...
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…