I am working to export data as csv its downloading only 1st 9 records total 10 on excel 1st is heading and 9 records then i want to export whole table from Db don't know whats gone wrong here is method below
public function ExportAll(){
$student = Students::all();
$temp = tmpfile();
$heading = array('Name', 'Group');
fputcsv($temp, $heading);
foreach($student as $row) {
fputcsv($temp, array($row['name'],$row['group']));
}
fseek($temp, 0);
echo fread($temp, 1024);
header('Content-Type: text/csv; charset=utf-8');
header('Content-Disposition: attachment; filename=Student.csv' );
fclose($temp);
die;
}
Its downloading only one row i want to download whole table usig this method Please help to fix route is as
Route::get('/student/ExportAll', 'StudentController@ExportAll');
here i have link to export as
<a href="/student/ExportAll">Export</a>