diff --git a/src/Helpers/menu_helper.php b/src/Helpers/menu_helper.php index 34c8ab9..aa68d69 100644 --- a/src/Helpers/menu_helper.php +++ b/src/Helpers/menu_helper.php @@ -82,3 +82,49 @@ function nest($item, $parent_id) return nest((new MenuModel())->orderBy('sequence', 'asc')->get()->getResultObject(), 0); } } + +/** + * The ugly for generate some html + * + * return string hrml + */ +if (!function_exists('build')) { + function build() { + + $html = ''; + foreach (menu() as $parent) { + $open = current_url() == base_url($parent->route) || in_array(uri_string(), array_column($parent->children, 'route')) ? 'menu-open' : ''; + $active = current_url() == base_url($parent->route) || in_array(uri_string(), array_column($parent->children, 'route')) ? 'active' : ''; + $link = base_url($parent->route); + + $html .= "
'; + $html .= $parent->title; + if (count($parent->children)) { + $html .= ""; + } + $html .= '
'; + $html .= ''; + if (count($parent->children)) { + $html .= "