I have a difficulty in forming a complicated laravel query:
This is the DB table:
Student ID (number), Status (String), Batch (number), Dismissed (Date), Withdrawal (Date)
I want to show in a view the following table:
Batch: all current Batches for example (1-5)
Active: total number of active student (Status = Active) in each batch
Dismissed: total number of dismissed student (Dismissed date is not null) in each batch
Postponed: total number of Postponed student (Status = Postponed) in each batch
Withdrawal: total number of Withdrawal student (Status = Withdrawal) in each batch
Intern: total number of Intern student (Status = Intern) in each batch
Alumni: total number of Alumni student (Status = Alumni) in each batch
Total of ID: total number of student in each batch
I manged to query all current batches in the controller:
public function summeryReport_pdf()
{
$batches = Student::distinct()->get(['Batch']);
//->where('Status', '=', 'ACTIVE')->count(['Status']);
// Send data to the view using loadView function of PDF facade
$pdf = PDF::loadView('SummeryReport', compact('batches'));
$pdf->save(storage_path().'_SummeryReport.pdf');
return $pdf->download('SummeryReport.pdf');
}
View:
@foreach($batches as $result)
<tr Style="border: 1px solid black; text-align:center;">
<td Style="border-right: 1px solid black; padding: 5px;">
</td>
</tr>
@endforeach
the goal is to achieve the following:
How to loop for each batch in the controller and send the query result to the view ?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire