I am trying to show a view through excel and for some reason the data is not being shown, can someone tell me what I am doing wrong here?
Here is the code:
$data2 = PositionApplied::select('PermRelief')->where('PermRelief','=','Permanent')->get();
$data1 = PositionApplied::select('PermRelief')->where('PermRelief','=','Relief')->get();
$perm = count($data2);
$relief = count($data1);
$total = $perm + $relief;
$percent1 = $perm/$total;
$permPercent = round((float)$percent1 * 100 ) . '%';
$percent2 = $relief/$total;
$reliefPercent = round((float)$percent2 * 100 ) . '%';
$percent3 = $total/$total;
$totalpercent = round((float)$percent3 * 100 ) . '%';
return Excel::create('Report', function($excel) use ($data,$perm,$relief,$permPercent,$reliefPercent,$totalpercent,$total) {
$excel->sheet('Applicant', function($sheet) use ($data)
{
$sheet->fromArray($data);
//$sheet->loadview('excelInfo');
});
$excel->sheet('Applicant1', function($sheet) use ($perm,$relif,$permPercent,$reliefPercent,$totalpercent,$total)
{
$sheet->loadview('excelInfo')->with('perm')->with('relief')->with('permPercent')->with('permPercent')->with('reliefPercent')->with('totalpercent')->with('total');
});
})->download($type);
}
All the data that I used are showing up in the excel why is that? I did a dd on it and return me their value in the controller, but why it is not showing in the excel after downloading? Can someone help me here? Thanks a lot