Level 122
public function export()
{
$products = Product::where('id',1)->get(); // your rules... get the products you want to export as a collection
// pass the products to the export class
return Excel::download(new ProductExport($products), 'patient.xlsx');
}
product export class
public function __construct($products)
{
$this->products = $products;
}
public function collection()
{
return $this->products;
}