Patients List Total Patients : {{ $totalPatients }}

{{-- --}} @forelse ($patients as $patient) @php // Get the most recent active patient clinic association $patientClinic = $patient->patientClinics ->where('status', 'active') ->sortByDesc('created_at') ->first(); $doctor = $patientClinic->doctor ?? null; $lastVisit = $patientClinic ? $patientClinic->created_at->format('d M Y') : 'N/A'; $profileImage = $patient->patient->profile_image ?? null; $initials = getInitials($patient->name); @endphp {{-- --}} @empty @endforelse
Patient PhoneDoctorAddress Last Visit Status
{{ $patient->patient->phone ?? 'N/A' }} @if ($doctor)
@php // Access the doctor profile through the doctor relationship $doctorProfile = $doctor->doctor; $doctorProfileImage = $doctorProfile->profile_image ?? null; $doctorInitials = getInitials($doctor->name); $avatarColorClass = getAvatarColorClass($doctor->name); @endphp @if ($doctorProfileImage && Storage::disk('public')->exists($doctorProfileImage)) {{ $doctor->name }} @else
{{ $doctorInitials }}
@endif
{{ $doctor->name }}

{{ $doctorProfile->specialization ?? 'General Practitioner' }}

@else Not assigned @endif
{{ $patient->patient->address ?? 'N/A' }} {{ $lastVisit }} {{ ucfirst($patient->patient->status) }}
No patients found.
@push('scripts') @endpush