Your post SHOUTED OUT AT ME when I visited the forum, and DESPITE your best efforts, I have no idea what you are asking.
If there are supposed to be blocks of code in your post, try formatting them.
Hello Folks, I have the following in a database- short format
YEAR NAME Subject Grade 2022 John English Pass 2023 John Maths Pass 2022 John Physical Edu Fail
I want the report or blade to look like below Year comes as sub heading then followed the exams as below;
REPORT
Name: John
Year: 2022
--------
English Pass Phys Edu Fail
Maths Pass
I passed everythig to blade where I have the following
foreach ($singleStudent as $key =>$student )
But I cannot seem to pull the year to look as above. Any idea or code snip ? Please...
@bashiro where is your <table> tags?
Do you want the subheading in the middle of the table?
Or one table for each year?
Try this:
{{-- ./resources/views/report.blade.php --}}
<h1>Report</h1>
<p>
<b>Student:</b> {{ $singleStudent->first()?->name ?? 'UNKNOWN' }}
</p>
@foreach($singleStudent->groupBy('year')->sortKeys() as $year => $records)
<h2>{{ $year }}</h2>
<table border="1">
<thead>
<tr>
<th>Subject</th>
<th>Grade</th>
</tr>
</thead>
<tbody>
@foreach($records as $record)
<tr>
<td>{{ $record->subject }}</td>
<td>{{ $record->grade }}</td>
</tr>
@endforeach
</tbody>
</table>
@endforeach
Please or to participate in this conversation.