@php // Collect possible flash toasts (your original code — keep as-is) $toasts = []; $map = [ 'success' => 'Success', 'error' => 'Error', 'warning' => 'Warning', 'info' => 'Info', ]; foreach ($map as $key => $title) { if (session()->has($key)) { $payload = session($key); $message = is_bool($payload) ? null : $payload; $toasts[] = [ 'type' => $key, 'title' => $title, 'message' => $message, ]; } } if ($errors && $errors->any()) { $toasts[] = [ 'type' => 'error', 'title' => 'Validation failed', 'message' => $errors->all(), ]; } if (session()->has('toast')) { $t = session('toast'); $toasts[] = [ 'type' => $t['type'] ?? 'info', 'title' => ucfirst($t['type'] ?? 'Info'), 'message' => $t['message'] ?? null, ]; } @endphp @if(count($toasts))