How can you pass a parameter from controller to route. For example, in my controller i want to redirect the user to a route and also attach ?userID=xyz to the route. How can I do it? So in my controller
public function mymethod(){
return route('getmydata', ['data'=> 1]);
}
I have a route named getmydata
Route::get('/data/{data}', function (Request $request, $data) {
...
})->name('getmydata');
How would i pass ?userID in my controller so my route can be /data/{data}?userID=xyz
Thanks
EDIT still not working:
My controller:
public function mymethod(){
$userID = xyz;
return route('getmydata', ['data'=> 1, 'userID' => $userID]);
}
And then in my route:
Route::get('/data/{data}/', function ($data, $userID) {
...
})->name('getmydata');
I'm getting
"Too few arguments to function App\\Providers\\RouteServiceProvider
I'm passing two parameters and expecting two. What am i missing?
the route should be /data/{data}?userID=xyz