user();
return [
'upcoming' => $user->consultations()
->approved()
->where('booking_date', '>=', today())
->orderBy('booking_date')
->orderBy('booking_time')
->get(),
'pending' => $user->consultations()
->pending()
->latest()
->get(),
'past' => $user->consultations()
->where(function ($query) use ($user) {
$query->whereIn('status', [
ConsultationStatus::Completed,
ConsultationStatus::Cancelled,
ConsultationStatus::NoShow,
])
->orWhere(function ($q) {
$q->where('status', ConsultationStatus::Approved)
->where('booking_date', '<', today());
});
})
->orderBy('booking_date', 'desc')
->paginate(10),
];
}
}; ?>
{{-- Header --}}
@if(session('success'))
{{ session('success') }}
@endif
{{-- Upcoming Consultations Section --}}
{{ __('booking.upcoming_consultations') }}
@if($upcoming->isNotEmpty())
@foreach($upcoming as $consultation)
{{ $consultation->booking_date->translatedFormat(app()->getLocale() === 'ar' ? 'l، j F Y' : 'l, F j, Y') }}
{{ \Carbon\Carbon::parse($consultation->booking_time)->format('g:i A') }}
{{-- Consultation Type Badge --}}
@if($consultation->consultation_type === ConsultationType::Free)
{{ __('booking.type_free') }}
@else
{{ __('booking.type_paid') }}
@endif
{{-- Status Badge --}}
{{ $consultation->status->label() }}
{{-- Payment Status (for paid consultations) --}}
@if($consultation->consultation_type === ConsultationType::Paid)
@if($consultation->payment_status === PaymentStatus::Received)
{{ __('booking.payment_received') }}
@else
{{ __('booking.payment_pending') }}
@endif
@endif
{{ __('booking.add_to_calendar') }}
@endforeach
@else
{{ __('booking.no_upcoming_consultations') }}
{{ __('booking.book_consultation') }}
@endif
{{-- Pending Requests Section --}}
{{ __('booking.pending_requests') }}
@if($pending->isNotEmpty())
@foreach($pending as $consultation)
{{ $consultation->booking_date->translatedFormat(app()->getLocale() === 'ar' ? 'l، j F Y' : 'l, F j, Y') }}
{{ \Carbon\Carbon::parse($consultation->booking_time)->format('g:i A') }}
{{ __('booking.submitted_on') }}: {{ $consultation->created_at->translatedFormat(app()->getLocale() === 'ar' ? 'j F Y' : 'F j, Y') }}
@if($consultation->problem_summary)
{{ Str::limit($consultation->problem_summary, 150) }}
@endif
{{ __('booking.pending_review') }}
@endforeach
@else
{{ __('booking.no_pending_requests') }}
@endif
{{-- Past Consultations Section --}}
{{ __('booking.past_consultations') }}
@if($past->isNotEmpty())
@foreach($past as $consultation)
{{ $consultation->booking_date->translatedFormat(app()->getLocale() === 'ar' ? 'l، j F Y' : 'l, F j, Y') }}
{{ \Carbon\Carbon::parse($consultation->booking_time)->format('g:i A') }}
{{-- Consultation Type Badge --}}
@if($consultation->consultation_type === ConsultationType::Free)
{{ __('booking.type_free') }}
@else
{{ __('booking.type_paid') }}
@endif
{{-- Status Badge --}}
@php
$statusColor = match($consultation->status) {
ConsultationStatus::Completed => 'zinc',
ConsultationStatus::Cancelled => 'red',
ConsultationStatus::NoShow => 'red',
ConsultationStatus::Approved => 'zinc',
default => 'zinc',
};
@endphp
{{ $consultation->status->label() }}
@endforeach
{{ $past->links() }}
@else
{{ __('booking.no_past_consultations') }}
@endif