I have table absentee_record
id | student_id | note | from_date | to_date |
---|---|---|---|---|
1 | 1 | Leave | 2021-06-06 | 2021-06-10 |
I want to get absentee_records
foreach date. Like it will be 5 rows foreach date.
Controller
$from_date = $request->input('from_date');
$to_date = $request->input('to_date');
$student_ids = [];
foreach($students as $student) {
$student_ids[] = $student->id;
}
$absentees = AbsenteeRecord::whereIn('student_id', $student_ids)->whereDate('from_date', '>=', $from_date)->whereDate('to_date', '<=', $to_date)->get();
<table class="table" width="100%">
<thead>
<tr>
<th>Date</th>
<th>Name</th>
<th>Tags</th>
<th>Note</th>
</tr>
</thead>
<tbody>
@foreach ($absentees as $absentee)
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
@endforeach
</tbody>
</table>
source https://stackoverflow.com/questions/67862728/get-data-foreach-date-in-from-date-to-date
No comments:
Post a Comment