@if ($sectionData && isset($sectionData['section_6']) && $sectionData['section_6']['section_6'] == 1)
{{ $sectionData['section_6']['title'] }}
{{ $sectionData['section_6']['subtitle'] }}
{{ __('clinic.view_all') }}
@foreach ($sectionData['section_6']['doctor_id'] as $doctor_id) @php // Fetch doctor with the associated user $doctor = \Modules\Clinic\Models\Doctor::where('id', $doctor_id) ->with('user') // Removed empty string in the relationship ->first(); if ($doctor) { $doctor_user = optional($doctor->user); $doctor_id = $doctor_user->id; // Ensure we are using the correct user ID $total_appointment = \Modules\Appointment\Models\Appointment::where('doctor_id', $doctor_id) ->where('status', 'checkout') ->count(); $reviews = \Modules\Clinic\Models\DoctorRating::where('doctor_id', $doctor_id)->get(); $average_rating = $reviews->isNotEmpty() ? round($reviews->avg('rating'), 1) : 0; $doctor->average_rating = $average_rating; $doctor->total_appointment = $total_appointment; } @endphp @if ($doctor)
@endif @endforeach
@endif @push('after-scripts') @endpush