58: foreach ($categoriasReal as $cat) { 59: $catMap[$cat['id']] = $cat['nombre']; 60: } 61: 62: $productosReal = $productsData->map(function ($p) use ($catMap) { 63: $attr = json_decode($p->atributos_json ?? '{}', true); 64: $offerPrice = isset($attr['offer_price']) && $attr['offer_price'] > 0 ? (float) $attr['offer_price'] : null; 65: 66: return [ 67: 'id' => $p->id_producto, 68: 'nombre' => $p->nombre, 69: 'desc' => $attr['descripcion'] ?? $p->descripcion ?? '', 70: 'precio' => $offerPrice ? $offerPrice : (float) $p->precio, 71: 'precio_raw' => (float) $p->precio, 72: 'precio_oferta' => $offerPrice, 73: 'img' => $p->imagen_url, 74: 'cat' => $p->categoria, 75: 'cat_nombre' => $catMap[$p->categoria] ?? ucfirst(strtolower($p->categoria ?? 'General')), 76: 'badge' => isset($attr['es_destacado']) && $attr['es_destacado'] ? 'Destacado' : '', 77: 'atributos_json' => $p->atributos_json, 78: 'atributos_json' => $p->atributos_json, 79: 'atributos_json' => $p->atributos_json 80: ]; 81: })->values()->toArray(); 82: } catch (\Exception $e) { 83: \Log::error("Error cargando datos del menú: " . $e->getMessage()); 84: } 85: } 86: 87: return [ 88: 'usuario' => [ 89: 'nombre' => auth()->user()->nombre_completo ?? 'Invitado', 90: 'nivel' => 'Cliente', 91: 'avatar' => 'https://images.unsplash.com/photo-1535713875002-d1d0cf377fde?auto=format&fit=crop&w=100&h=100' 92: ], 93: 'promociones' => [ 94: ['id' => 1, 'titulo' => 'Sabor Real', 'sub' => 'Disfruta de nuestros platos recién preparados', 'img' => 'https://images.unsplash.com/photo-1555939594-58d7cb561ad1?q=80&w=1200&auto=format&fit=crop', 'color' => 'from-orange-600 to-red-900'], 95: ], 96: 'categorias' => !empty($categoriasReal) ? $categoriasReal : [ 97: ['id' => 'general', 'nombre' => 'Carta General', 'icono' => 'utensils'] 98: ], 99: 'productos' => $productosReal 100: ]; 101: } 102: 103: private function getIconForCategory($nombre) 104: { 105: $nombre = strtolower($nombre); 106: if (str_contains($nombre, 'bebida') || str_contains($nombre, 'licor') || str_contains($nombre, 'tomar')) 107: return 'wine'; 108: if (str_contains($nombre, 'parrill') || str_contains($nombre, 'carne')) 109: return 'flame'; 110: if (str_contains($nombre, 'entrada')) 111: return 'utensils'; 112: if (str_contains($nombre, 'postre') || str_contains($nombre, 'dulce')) 113: return 'cake';