@php use App\Support\Session; // getFlashes() consumes, so drawing this twice is safe: the second call finds nothing. // That is what lets the subheader draw it in place while the layout keeps the fallback // for pages that have no subheader. $flashes = Session::getFlashes(); @endphp @if (!empty($flashes)) @php $map = ['success' => 'alert-success', 'error' => 'alert-danger', 'info' => 'alert-info', 'warning' => 'alert-warning']; $icons = ['success' => 'fa-check-circle', 'error' => 'fa-times-circle', 'info' => 'fa-info-circle', 'warning' => 'fa-exclamation-triangle']; // Split urgent (problem) flashes from confirmations so screen readers treat them // appropriately: errors/warnings are announced assertively (they interrupt and // surface validation failures right away); success/info stay in a polite region // so routine confirmations never pre-empt what the user is reading. $urgentTypes = ['error', 'warning']; $urgent = array_intersect_key($flashes, array_flip($urgentTypes)); $polite = array_diff_key($flashes, array_flip($urgentTypes)); // Count problem messages so the summary heading can name how many failed. $urgentCount = 0; foreach ($urgent as $messages) { $urgentCount += count($messages); } @endphp @if (!empty($urgent)) @endif @if (!empty($polite))
@foreach ($polite as $type => $messages) @foreach ($messages as $msg)
{{ $msg }}
@endforeach @endforeach
@endif @endif