Bus Booking

{{ $packagePrice->package->title }}

From {{ optional($packagePrice->startPoint)->name ?? 'Not specified' }}Sabarimala

Bus {{ $packagePrice->busType->name }}
Price per seat ₹{{ $packagePrice->price }}
{{-- Itinerary with correct dates --}}

Travel Itinerary

    @foreach($packagePrice->package->segments as $segment) @php $segmentDate = \Carbon\Carbon::parse($date)->addDays($segment->day_number - 1); @endphp
  • {{ optional($segment->fromLocation)->name ?? 'Start' }} (Dep: {{ \Carbon\Carbon::parse($segment->departure_time)->format('h:i A') }}, {{ $segmentDate->format('Y-m-d') }}) → {{ optional($segment->toLocation)->name ?? 'End' }} (Arr: {{ \Carbon\Carbon::parse($segment->arrival_time)->format('h:i A') }}, {{ $segmentDate->format('Y-m-d') }})
  • @endforeach
{{-- Legend --}}
Available
Booked
Selected
{{-- Seat Form --}}
@csrf @php $seats = $packagePrice->busType->seats->values(); $bookedSeatIds = $bookedSeatIds ?? []; $seatIndex = 0; $busLayouts = [ 'volvo_49' => ['rows'=>11,'left'=>2,'right'=>2,'last_row'=>5], 'glider_45' => ['rows'=>10,'left'=>2,'right'=>2,'last_row'=>5], '2x3' => ['rows'=>8,'left'=>2,'right'=>3,'first_row_right'=>3,'last_row'=>6] ]; $busTypeToLayout = [4=>'2x3', 2=>'volvo_49', 3=>'glider_45']; $layoutKey = $busTypeToLayout[$packagePrice->bus_type_id]; $layout = $busLayouts[$layoutKey]; function renderSeat($seat, $bookedSeatIds){ if(!$seat) return '
'; $isBooked = in_array($seat->id, $bookedSeatIds); return '
'; } @endphp
🛞
@if(isset($layout['first_row_right']))
@for($col=0;$col<$layout['first_row_right'];$col++) {!! renderSeat($seats->get($seatIndex++), $bookedSeatIds) !!} @endfor
@endif @for($row=0;$row<$layout['rows'];$row++)
@for($col=0;$col<$layout['left'];$col++) {!! renderSeat($seats->get($seatIndex++), $bookedSeatIds) !!} @endfor
@for($col=0;$col<$layout['right'];$col++) {!! renderSeat($seats->get($seatIndex++), $bookedSeatIds) !!} @endfor
@endfor @if(isset($layout['last_row']))
@for($col=0;$col<$layout['last_row'];$col++) {!! renderSeat($seats->get($seatIndex++), $bookedSeatIds) !!} @endfor
@endif