@php $tenant = \App\Support\Facades\Tenancy::get(); $student = $reportCard->student; $primary = $tenant->brand_primary_color ?: '#4f46e5'; // Union of every subject that appears in any of the three terms, in first-seen // order, so the table has one row per subject even if a term is missing marks // for it (blank cells rather than dropping the row). $subjects = []; foreach ($termResults as $result) { if (! $result) { continue; } foreach ($result->subjectResults as $rs) { $name = $rs->examSchedule->courseOffering->subject->name; if (! isset($subjects[$name])) { $subjects[$name] = true; } } } $subjects = array_keys($subjects); $fmt = fn ($n) => $n === null ? '—' : (floor($n) == $n ? (string) (int) $n : rtrim(rtrim(sprintf('%.2f', $n), '0'), '.')); @endphp Report Card — {{ $student->fullName() }}

{{ $tenant->name }}

@if($student->branch)

Branch: {{ $student->branch->name }}

@endif

Student Report Card

{{ $reportCard->academicSession->name }}

@if($student->photo_path) Photo of {{ $student->fullName() }} @else {{ strtoupper(mb_substr($student->first_name, 0, 1).mb_substr($student->last_name, 0, 1)) }} @endif

{{ $student->fullName() }}

{{ $student->student_code }}

Class / Section

{{ $student->section?->schoolClass?->name }} - {{ $student->section?->name }}

Roll No.

{{ $student->roll_number ?? '—' }}

Session

{{ $reportCard->academicSession->name }}

@foreach($termResults as $label => $result) @endforeach @foreach($termResults as $label => $result) @endforeach @forelse($subjects as $subjectName) @php // termResults() returns a plain array (Result|null per // term label), not a Collection — wrap it before chaining. $subjectRowsPerTerm = collect($termResults)->map(fn ($result) => $result?->subjectResults->first(fn ($r) => $r->examSchedule->courseOffering->subject->name === $subjectName)); // Only components with a pass mark set AND that failed — // most components have no pass mark at all, so this stays // empty (and the extra row hidden) for the common case. $failedComponentsByTerm = $subjectRowsPerTerm->mapWithKeys(fn ($rs, $label) => [ $label => $rs?->components->filter(fn ($c) => $c->is_pass === false) ?? collect(), ])->filter(fn ($failed) => $failed->isNotEmpty()); @endphp @foreach($termResults as $result) @php $rs = $result?->subjectResults->first(fn ($r) => $r->examSchedule->courseOffering->subject->name === $subjectName); @endphp @if($rs) @else @endif @endforeach @if($failedComponentsByTerm->isNotEmpty()) @endif @empty @endforelse @if(! empty($subjects)) @foreach($termResults as $result) @if($result) @else @endif @endforeach @endif
Subject{{ $label }}
Total Obtained Status
{{ $subjectName }}{{ $fmt($rs->full_marks) }} {{ $fmt($rs->marks_obtained) }} {{ $rs->is_pass ? 'Pass' : 'Fail' }}— — —
@foreach($failedComponentsByTerm as $label => $failed) @foreach($failed as $component) {{ $label }} — {{ $component->name }}: {{ $fmt($component->marks_obtained) }}/{{ $component->max_marks }} (needs {{ $fmt($component->pass_marks) }}) @endforeach @endforeach
No published results available yet.
Total Marks{{ $fmt($result->total_full_marks) }} {{ $fmt($result->total_marks_obtained) }} {{ $result->is_pass ? 'Pass' : 'Fail' }}— — —
@foreach($termResults as $label => $result)

{{ $label }}

@if($result) {{ $result->percentage }}% {{ $result->letter_grade }} @else Not available @endif

@if($result?->rank)

Position in Section: {{ $result->rank }}

@endif
@endforeach
@if($gpaSummary && ($gpaSummary->cumulative_percentage || $gpaSummary->cgpa))
Overall (This Session)
@if($gpaSummary->cumulative_percentage)
{{ $gpaSummary->cumulative_percentage }}%
Average
@endif @if($gpaSummary->cgpa)
{{ $gpaSummary->cgpa }}
CGPA
@endif @if($overallRank)
{{ $overallRank }}
Merit Position in Section
@endif @if($lastPromotionRank)
{{ $lastPromotionRank }}
Position Last Session
@endif
@elseif($lastPromotionRank)
Overall (This Session)
{{ $lastPromotionRank }}
Position Last Session
@endif
@if($classTeacherSignaturePath) Class Teacher signature @else
@endif

In-charge

@if($classTeacherName)

{{ $classTeacherName }}

@endif
@php($principal = $signatureBlocks->first()) @if($principal && $principal['path']) {{ $principal['title'] }} signature @else
@endif

{{ $principal['title'] ?? 'Principal / Headmaster' }}

@if($principal && $principal['name'])

{{ $principal['name'] }}

@endif

Guardian