@php $role = session('login_role'); $rolePath = $role === 'staff' ? 'staff' : 'student'; $portal = $role === 'staff' ? 'STAFF PORTAL' : 'STUDENT PORTAL'; $roomsById = []; foreach ($rooms ?? [] as $room) { $roomsById[$room['id']] = $room['room_name']; } $totalVisits = count($records ?? []); $lastVisit = $records[0] ?? null; $totalSpent = collect($records ?? [])->sum(function($item){ return (float)($item['cost'] ?? 0); }); @endphp Treatment History

Visit History

{{ now()->format('D, d M Y') }}

Treatment History

Your complete dental visit records

TOTAL VISITS

{{ $totalVisits }}

Since registration

LAST VISIT

{{ $lastVisit ? date('d M Y', strtotime($lastVisit['treatment_date'])) : '-' }}

{{ $lastVisit['treatment_type'] ?? $lastVisit['treatment_name'] ?? 'No record yet' }}

TOTAL SPENT

RM{{ number_format($totalSpent, 2) }}

From medical allocation

@if(count($records ?? []) > 0) @foreach($records as $record) @endforeach
DATE TREATMENT ROOM DOCTOR COST DETAILS
{{ !empty($record['treatment_date']) ? date('d M Y', strtotime($record['treatment_date'])) : '-' }} {{ $record['treatment_type'] ?? $record['treatment_name'] ?? '-' }} {{ $roomsById[$record['room_id'] ?? ''] ?? '-' }} {{ $record['doctor_name'] ?? '-' }} RM{{ number_format((float)($record['cost'] ?? 0), 2) }} View →
@else
No treatment history available yet.
@endif