@php $classifyDestinationError = static function (string $key): array { if (in_array($key, ['name', 'slug', 'airport_code', 'image', 'main_image', 'description'], true)) { return ['step' => 'basic', 'tab' => null, 'section' => 'Basics']; } $highlights = [ 'adventure_' => ['adventure', 'Highlights · Adventure'], 'culture_' => ['culture', 'Highlights · Culture'], 'beach_' => ['beach', 'Highlights · Beaches'], 'food_' => ['food', 'Highlights · Food'], ]; foreach ($highlights as $prefix => [$tab, $section]) { if (str_starts_with($key, $prefix)) { return ['step' => 'content', 'tab' => $tab, 'section' => $section]; } } if (str_starts_with($key, 'flights') || $key === 'deleted_flight_ids') { return ['step' => 'additional', 'tab' => 'flights', 'section' => 'Extras · Flights']; } if (str_starts_with($key, 'things_to_know')) { return ['step' => 'additional', 'tab' => 'tips', 'section' => 'Extras · Travel tips']; } if (str_starts_with($key, 'faq_')) { return ['step' => 'additional', 'tab' => 'faqs', 'section' => 'Extras · FAQs']; } return ['step' => 'basic', 'tab' => null, 'section' => 'Form']; }; $groupedErrors = []; foreach ($errors->getBag('default')->messages() as $key => $messages) { $meta = $classifyDestinationError($key); $groupKey = $meta['section']; $groupedErrors[$groupKey] ??= [ 'step' => $meta['step'], 'tab' => $meta['tab'], 'messages' => [], ]; foreach ($messages as $message) { $groupedErrors[$groupKey]['messages'][] = $message; } } @endphp
any()) x-cloak @endunless role="alert" aria-live="polite" aria-labelledby="dest-error-pane-title" >

Please fix these issues before saving

@foreach ($groupedErrors as $section => $group)

{{ $section }}

    @foreach ($group['messages'] as $message)
  • @endforeach
@endforeach

Basics