{{-- Shared Flight Booking form fields. Wrapped by create.blade.php and edit.blade.php. Expects: $item (null on create), $customers, $bookings, $statuses, $cities. --}} @php $app = $item ?? null; $flightDate = old('flight_date', $app && $app->flight_date ? $app->flight_date->format('Y-m-d') : ''); // Existing route strings may be "DAC→DXB", "DAC -> DXB" or "Dhaka -> Dubai"; // split them back and match each side by code or city name, so the // From/To pickers prefill on edit. $routeParts = $app && $app->route ? preg_split('/\s*(?:→|->|—|–|-)\s*/', trim($app->route), 2) : []; $fromValue = old('from', ''); $toValue = old('to', ''); foreach ([0 => 'fromValue', 1 => 'toValue'] as $idx => $target) { $part = $routeParts[$idx] ?? ''; if ($$target === '' && $part !== '') { $match = $cities->first(fn ($c) => strcasecmp((string) $c->city, $part) === 0 || (string) $c->code === $part); $$target = $match ? $match->city : ''; } } @endphp