Okay so I have an individual ones for id's, but after doing a search I want to also be able to export all the results on the page. So, this would be the function for it but all it's doing is printing all the results from the database(because I don't know how to implement the other method and that is what I'm asking for help with) basically:
public function pdfAll() {
$users = User::select('id', 'first_name','last_name', 'email')->get();
Excel::create('AllUsers', function($excel) use($users) {
$excel->sheet('Sheet 1', function($sheet) use($users) {
$sheet->fromArray($users, null, 'A1', false, false);
$headings = array('', 'First Name','Last Name','Email');
$sheet->prependRow(1, $headings);
});
})->export('pdf');
}
The view is generated with this:
return view('users.index')
->with(['tableData'=> $userTable->render(),
'navData' => $navBar->render()]);
So I can't export view without "tableData" but that holds the code for the info we want to print in the table on the view-> the id's aren't there so I can't access that. Thanks to the search query we have set up for the page. Idk how much code I need to share or what code to share. I'm mainly asking for ideas on what to do. Like should I try to get the old search from a request somehow? Should I try using the query string from the search results?