add check roles on sidebar

This commit is contained in:
Daeng Deni Mardaeni 2024-10-14 17:53:29 +07:00
parent eb355ebe88
commit 8e4784c6ce
2 changed files with 8 additions and 0 deletions

View File

@ -8,6 +8,10 @@ import $ from "jquery";
window.jQuery = $;
window.$ = $;
import Swal from "sweetalert2";
window.Swal = Swal;
window.swal = Swal;
import TomSelect from "tom-select";
document.querySelectorAll(".tomselect").forEach((el) => {
@ -15,12 +19,14 @@ document.querySelectorAll(".tomselect").forEach((el) => {
plugins: ["dropdown_input"],
create: false,
createOnBlur: true,
closeButton: true,
};
new TomSelect(el, settings);
});
import toast from "toastr";
window.toast = toast;
import "toastr/build/toastr.css";
document.querySelectorAll(".toastr").forEach((el) => {

View File

@ -102,6 +102,7 @@
@if(is_array($menu->sub))
<div class="menu-accordion gap-0.5 pl-[10px] relative before:absolute before:left-[20px] before:top-0 before:bottom-0 before:border-l before:border-gray-200">
@foreach($menu->sub as $sub)
@if(auth()->user()->hasRole($sub->roles))
<div class="menu-item {{ request()->routeIs($sub->path.'.*') && in_array(request()->route()->getName(), [$sub->path.'.index', $sub->path.'.create', $sub->path.'.edit']) ? 'active' : '' }}">
<a class="menu-link gap-[14px] pl-[10px] pr-[10px] py-[8px] border border-transparent items-center grow menu-item-active:bg-secondary-active dark:menu-item-active:bg-coal-300 dark:menu-item-active:border-gray-100 menu-item-active:rounded-lg hover:bg-secondary-active dark:hover:bg-coal-300 dark:hover:border-gray-100 hover:rounded-lg"
href="{{ $sub->path ? route($sub->path.'.index') : '' }}" tabindex="0">
@ -114,6 +115,7 @@
</span>
</a>
</div>
@endif
@endforeach
</div>
@endif