Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
agungsugiarto committed Apr 1, 2020
2 parents 3ab7067 + 0fe177b commit 617ce84
Showing 1 changed file with 26 additions and 26 deletions.
52 changes: 26 additions & 26 deletions src/Helpers/menu_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,44 +84,44 @@ function nest($item, $parent_id)
}

/**
* The ugly for generate some html
*
* The ugly for generate some html.
*
* return string hrml
*/
if (!function_exists('build')) {
function 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 .= "<li class='nav-item has-treeview {$open}'>";
$html .= "<a href='{$link}' class='nav-link {$active}'>";
$html .= "<i class='nav-icon {$parent->icon}'></i>";
$html .= '<p>';
$html .= $parent->title;
if (count($parent->children)) {
$html .= "<i class='right fas fa-angle-left'></i>";
}
$html .= '</p>';
$html .= '</a>';
if (count($parent->children)) {
$html .= "<a href='{$link}' class='nav-link {$active}'>";
$html .= "<i class='nav-icon {$parent->icon}'></i>";
$html .= '<p>';
$html .= $parent->title;
if (count($parent->children)) {
$html .= "<i class='right fas fa-angle-left'></i>";
}
$html .= '</p>';
$html .= '</a>';
if (count($parent->children)) {
$html .= "<ul class='nav nav-treeview'>";
foreach ($parent->children as $child) {
$link_child = base_url($child->route);
$active_child = current_url() == base_url($child->route) ? 'active' : '';
$html .= "<li class='nav-item has-treeview'>";
$html .= "<a href='{$link_child}'";
$html .= "class='nav-link {$active_child}'>";
$html .= "<i class='nav-icon {$child->icon}'></i>";
$html .= "<p>{$child->title}</p>";
$html .= '</a>';
$html .= '</li>';
}
$html .= '</ul>';
foreach ($parent->children as $child) {
$link_child = base_url($child->route);
$active_child = current_url() == base_url($child->route) ? 'active' : '';
$html .= "<li class='nav-item has-treeview'>";
$html .= "<a href='{$link_child}'";
$html .= "class='nav-link {$active_child}'>";
$html .= "<i class='nav-icon {$child->icon}'></i>";
$html .= "<p>{$child->title}</p>";
$html .= '</a>';
$html .= '</li>';
}
$html .= '</ul>';
}
$html .= '</li>';
}

Expand Down

0 comments on commit 617ce84

Please sign in to comment.