@extends('layouts.admin') @section('content')

Itineraries

@php // Check if the start and end dates are available $start_date = $journey->start_date ? \Carbon\Carbon::parse($journey->start_date) : null; $end_date = $journey->end_date ? \Carbon\Carbon::parse($journey->end_date) : null; // If there are no start and end dates, skip the itinerary display if (!$start_date || !$end_date) { $showItineraries = false; } else { $days = $start_date->diffInDays($end_date); $groupedItineraries = $itineraries->groupBy('date'); $showItineraries = true; } @endphp
Itineraries
@if (!$showItineraries)
No start or end date is set for the journey. Please set the dates to view itineraries.
@else
@for ($i = 0; $i <= $days; $i++) @php $currentDate = $start_date->copy()->addDays($i)->format('Y-m-d'); $dayItineraries = $groupedItineraries->get($currentDate, []); @endphp
Day {{ $i + 1 }} - {{ \Carbon\Carbon::parse($currentDate)->format('d M Y') }}
@foreach ($dayItineraries as $key => $itinerary)
Slot {{ $key + 1 }}:
Start Time: {{ \Carbon\Carbon::parse($itinerary->start_time)->format('H:i') }}
Description: {{ $itinerary->description }}
@endforeach @if ($dayItineraries && $dayItineraries->isEmpty())
No itineraries available for this day.
@endif
@endfor
@endif
@endsection @section('script') @endsection