user(); return [ 'upcomingConsultation' => $user->consultations() ->approved() ->where('booking_date', '>=', today()) ->orderBy('booking_date') ->orderBy('booking_time') ->first(), 'activeTimelinesCount' => $user->timelines()->active()->count(), 'latestTimeline' => $user->timelines()->active()->latest()->first(), 'recentUpdates' => TimelineUpdate::whereHas('timeline', fn ($q) => $q->where('user_id', $user->id)) ->latest() ->take(3) ->with('timeline') ->get(), 'pendingBookingsCount' => $user->consultations()->pending()->count(), 'canBookToday' => ! $user->consultations() ->whereDate('booking_date', today()) ->whereIn('status', ['pending', 'approved']) ->exists(), ]; } }; ?>
{{-- Welcome Section --}}
{{ __('client.dashboard.welcome', ['name' => auth()->user()->full_name]) }} {{ now()->locale(app()->getLocale())->translatedFormat(app()->getLocale() === 'ar' ? 'l، j F Y' : 'l, F j, Y') }}
{{-- Widgets Grid --}}
{{-- Upcoming Consultation Widget --}}
{{ __('client.dashboard.upcoming_consultation') }} @if ($upcomingConsultation)
@if (app()->getLocale() === 'ar') {{ $upcomingConsultation->booking_date->format('d/m/Y') }} @else {{ $upcomingConsultation->booking_date->format('m/d/Y') }} @endif
{{ \Carbon\Carbon::parse($upcomingConsultation->booking_time)->format('g:i A') }}
@if ($upcomingConsultation->consultation_type->value === 'free') {{ $upcomingConsultation->consultation_type->label() }} @else {{ $upcomingConsultation->consultation_type->label() }} @endif {{ $upcomingConsultation->status->label() }}
{{ __('client.dashboard.view_details') }}
@else
{{ __('client.dashboard.no_upcoming') }}
{{ __('client.dashboard.book_first') }}
@endif
{{-- Active Cases Widget --}}
{{ __('client.dashboard.active_cases') }} @if ($activeTimelinesCount > 0)
{{ $activeTimelinesCount }} {{ trans_choice('client.dashboard.cases_count', $activeTimelinesCount) }}
@if ($latestTimeline) @php $latestUpdate = $latestTimeline->updates()->reorder()->latest()->first(); @endphp @if ($latestUpdate)
{{ __('client.dashboard.latest_update') }}: {{ Str::limit($latestUpdate->update_text, 100) }}
@endif @endif
{{ __('client.dashboard.view_all_cases') }}
@else
{{ __('client.dashboard.no_cases') }}
@endif
{{-- Recent Updates Widget --}}
{{ __('client.dashboard.recent_updates') }} @if ($recentUpdates->isNotEmpty())
@foreach ($recentUpdates as $update)
{{ $update->timeline->case_name }} {{ $update->created_at->locale(app()->getLocale())->diffForHumans() }} {{ Str::limit($update->update_text, 80) }}
@endforeach
@else
{{ __('client.dashboard.no_updates') }}
@endif
{{-- Booking Status Widget --}}
{{ __('client.dashboard.booking_status') }}
@if ($pendingBookingsCount > 0)
{{ trans_choice('client.dashboard.pending_bookings', $pendingBookingsCount, ['count' => $pendingBookingsCount]) }}
@endif
@if ($canBookToday)
{{ __('client.dashboard.can_book') }}
@else
{{ __('client.dashboard.cannot_book') }}
@endif
{{ __('client.dashboard.book_consultation') }}