I am trying to export partial data from my table not all data, I am using Maatwebsite plugin
I have tried below code in controller
public function report(Request $request)
{
$sdate = $request->query('sdate');
$edate = $request->query('edate');
$report = Report::whereDate('created_at', '>=', $sdate)
->whereDate('created_at', '<=', $edate)
->get();
return Excel::download($report, 'report.xlsx');
}
In this time I am getting empty excel file.
I am able to get all data after creating app/export
like below
app/export/ReportExport.php
public function collection()
{
return Report::all();
}
but how I can I do it in controller ? or how can I sent $report data controller to collection ?