$string = Str::after(url()->previous(), '?');
OR
$string = $request->getQueryString();
May 10, 2022
4
Level 1
Laravel Pass Current Request Query String To Another Controller Method
i have a list of members i would like to export based on parameters in the current url request query string. for example, in the members_list page, /members?gender=men&day-born=friday. i can already generate and download the data doing so: /export?gender=men&day-born=friday
how do i generate the export route keeping the current members_list page url request query string and download the data without leaving the members_list page?
Level 8
@croftCoder Without your code it would be super hard to help you.
class ExampleController
{
public function doTheThing(Request $request)
{
$string = Str::after(url()->previous(), '?');
// Do the thing with the string here
// I guess
return redirect()->intended('/export?' . $string);
}
}
Please or to participate in this conversation.