This commit is contained in:
Lizandro Guarnizo
2026-05-27 11:44:07 -05:00
parent 313e57aace
commit b8de9ee666
2 changed files with 40 additions and 14 deletions
+36 -13
View File
@@ -63,19 +63,38 @@ try {
error_log("Estructura tabla menus: " . json_encode($tableStructure));
// Consulta adaptada a la estructura real de la tabla existente
$menusQuery = "SELECT
id,
name,
title,
description,
welcome_message,
parent_id,
is_root,
is_active,
order_position,
created_at,
updated_at
FROM menus ORDER BY order_position ASC, id ASC";
// Incluir menu_type solo si la columna existe (migración puede no haberse ejecutado)
$hasMenuType = !empty($db->fetchAll("SHOW COLUMNS FROM menus LIKE 'menu_type'"));
if ($hasMenuType) {
$menusQuery = "SELECT
id,
name,
title,
description,
welcome_message,
parent_id,
is_root,
is_active,
order_position,
created_at,
updated_at,
menu_type
FROM menus ORDER BY order_position ASC, id ASC";
} else {
$menusQuery = "SELECT
id,
name,
title,
description,
welcome_message,
parent_id,
is_root,
is_active,
order_position,
created_at,
updated_at
FROM menus ORDER BY order_position ASC, id ASC";
}
$menus = $db->fetchAll($menusQuery);
error_log("Menús obtenidos: " . count($menus) . " registros");
@@ -90,6 +109,10 @@ try {
if (!isset($menu['welcome_message'])) {
$menu['welcome_message'] = '';
}
// menu_type: garantizar que siempre exista el campo
if (!isset($menu['menu_type'])) {
$menu['menu_type'] = 'main';
}
}
error_log("Menús encontrados: " . count($menus));