I'm using Matt Stauffer CSV export package. Using Reporting::all() I get the expected result and the CSV report is downlooaded successfully. But using the below code I only get empty result. Just the csv file with columns, not a single row.
public function export($from, $to)
{
$reports = Reporting::whereBetween('reportDate',[date('m-d-Y', $from), date('m-d-Y', $to)]);
$csv = \League\Csv\Writer::createFromFileObject(new \SplTempFileObject());
$csv->insertOne(\Schema::getColumnListing('reports'));
foreach ($reports as $rep) {
$csv->insertOne($rep->toArray());
}
//return \Response::download($csv->output('reports.csv'));
return $csv->output('reports.csv');
}
Is there anything wrong I'm doing in the whereBetween condition?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire