"autoload": {
"psr-4": {
"App\\": "app/",
"Database\\Factories\\": "database/factories/",
"Database\\Seeders\\": "database/seeders/"
},
"files": [
"app/Helps/helpers.php"
]
},
<?php
if (!function_exists('renderDropdown')) {
function renderDropdown($data)
{
if (array_key_exists('target', $data) && $data['target'] === 'dropdown') {
echo '<li class="sidebar-nav-dropdown">';
echo '<a class="nav-link" href="#">';
if ($data['hasIcon'] === true && $data['iconType'] === 'coreui') {
echo '<i class="' . $data['icon'] . ' sidebar-nav-icon"></i>';
}
echo $data['name'] . '</a>';
echo '<ul class="sidebar-nav-dropdown-items">';
renderDropdown($data['elements']);
echo '</ul></li>';
} else {
for ($i = 0; $i < count($data); $i++) {
if ($data[$i]['target'] === 'link') {
echo '<li class="sidebar-nav-item">';
echo '<a class="nav-link" href="' . url($data[$i]['slug']) . '">';
echo '<span class="sidebar-nav-icon"></span>' . $data[$i]['name'] . '</a></li>';
} elseif ($data[$i]['target'] === 'dropdown') {
renderDropdown($data[$i]);
}
}
}
}
}
if (!function_exists('renderDropdownForMenuEdit')) {
function renderDropdownForMenuEdit($data, $role)
{
if (array_key_exists('slug', $data) && $data['slug'] === 'dropdown') {
echo '<tr>';
echo '<td>';
if ($data['hasIcon'] === true && $data['iconType'] === 'coreui') {
echo '<svg class="nav-icon edit-menu-icon"><use xlink:href="/assets/icons/coreui/free-symbol-defs.svg#' . $data['icon'] . '"></use></svg>';
echo '<i class="' . $data['icon'] . '"></i>';
}
echo '</td>';
echo '<td>' . $data['slug'] . '</td>';
echo '<td>' . $data['name'] . '</td>';
echo '<td></td>';
echo '<td>' . $data['sequence'] . '</td>';
echo '<td>';
echo '<a class="btn btn-success" href="' . route('menu.up', ['id' => $data['id']]) . '"><i class="cil-arrow-thick-top"></i></a>';
echo '</td>';
echo '<td>';
echo '<a class="btn btn-success" href="' . route('menu.down', ['id' => $data['id']]) . '"><i class="cil-arrow-thick-bottom"></i></a>';
echo '</td>';
echo '<td>';
echo '<a class="btn btn-primary" href="' . route('menu.show', ['id' => $data['id']]) . '">Show</a>';
echo '</td>';
echo '<td>';
echo '<a class="btn btn-primary" href="' . route('menu.edit', ['id' => $data['id']]) . '">Edit</a>';
echo '</td>';
echo '<td>';
echo '<a class="btn btn-danger" href="' . route('menu.delete', ['id' => $data['id']]) . '">Delete</a>';
echo '</td>';
echo '</tr>';
renderDropdownForMenuEdit($data['elements'], $role);
} else {
for ($i = 0; $i < count($data); $i++) {
if ($data[$i]['slug'] === 'link') {
echo '<tr>';
echo '<td>';
echo '<i class="cil-arrow-thick-to-right"></i>';
echo '</td>';
echo '<td>' . $data[$i]['slug'] . '</td>';
echo '<td>' . $data[$i]['name'] . '</td>';
echo '<td>' . $data[$i]['href'] . '</td>';
echo '<td>' . $data[$i]['sequence'] . '</td>';
echo '<td>';
echo '<a class="btn btn-success" href="' . route('menu.up', ['id' => $data[$i]['id']]) . '"><i class="cil-arrow-thick-top"></i></a>';
echo '</td>';
echo '<td>';
echo '<a class="btn btn-success" href="' . route('menu.down', ['id' => $data[$i]['id']]) . '"><i class="cil-arrow-thick-bottom"></i></a>';
echo '</td>';
echo '<td>';
echo '<a class="btn btn-primary" href="' . route('menu.show', ['id' => $data[$i]['id']]) . '">Show</a>';
echo '</td>';
echo '<td>';
echo '<a class="btn btn-primary" href="' . route('menu.edit', ['id' => $data[$i]['id']]) . '">Edit</a>';
echo '</td>';
echo '<td>';
echo '<a class="btn btn-danger" href="' . route('menu.delete', ['id' => $data[$i]['id']]) . '">Delete</a>';
echo '</td>';
echo '</tr>';
} elseif ($data[$i]['slug'] === 'dropdown') {
renderDropdownForMenuEdit($data[$i], $role);
}
}
}
}
}