The problem of searching results and downloading under laravel.

the download page and the search page are the same page, and you need to download the search results as files.
now the search and download methods are written, but you don"t know how to pass the parameters of get when you download it. Or send the search results directly to the download method.
is similar to this feeling.
I don"t know how to do either way of thinking.

public function search(Request $request)
{
    $keywords = [];
    $searchResult = [DB]
    return $searchResult;
}

public function download(Request $request)
{
     //1.
     $data = $searchResult;
     //2.get
    
    return CSV::download($data, $header, $filename, true);

}
Apr.29,2022

change the search method slightly.

  

resolved.
using cache, you can temporarily save the results and then take them out in the next method.

Menu