{{-- LOOPING GMENU --}}
@foreach ($gmenu as $g)
{{-- Hide Test Menu --}}
@if ($g->gmenu == 'test')
@continue
@endif
@if ($g->gmenu == 'blankx')
{{-- Query DMenu --}}
@php
$querydmenu = DB::table('sys_dmenu')
->join('sys_auth', 'sys_dmenu.dmenu', '=', 'sys_auth.dmenu')
->whereIn('sys_auth.idroles', $users_rules)
->where([
'sys_dmenu.isactive' => '1',
'sys_dmenu.show' => '1',
'sys_auth.isactive' => '1',
'sys_dmenu.gmenu' => $g->gmenu,
])
->select('sys_dmenu.*')
->distinct()
->orderBy('sys_dmenu.urut', 'asc')
->get();
@endphp
@foreach ($querydmenu as $d)
@php
$count = 0;
$user = auth()->user();
if ($d->notif) {
if (str_starts_with($d->notif, 'NOTIF:')) {
$keyword = explode(':', $d->notif)[1];
$count = $user->unreadNotifications
->filter(
fn($n) => str_contains(
strtolower(json_encode($n->data)),
strtolower($keyword),
),
)
->count();
} else {
try {
$sql = str_replace(
['{user_id}', '{idroles}', '{id_applicant}', '{idpegawai}'],
[
$user->id,
$user->idroles,
$user->id_applicant ?? 0,
$user->idpegawai ?? 0,
],
$d->notif,
);
$count = DB::select($sql)[0]->notif ?? 0;
} catch (\Exception $e) {
}
}
}
@endphp
-
@endforeach
@else
@php
$querydmenu = DB::table('sys_dmenu')
->join('sys_auth', 'sys_dmenu.dmenu', '=', 'sys_auth.dmenu')
->whereIn('sys_auth.idroles', $users_rules)
->where([
'sys_dmenu.isactive' => '1',
'sys_dmenu.show' => '1',
'sys_auth.isactive' => '1',
'sys_dmenu.gmenu' => $g->gmenu,
])
->select('sys_dmenu.*')
->distinct()
->orderBy('sys_dmenu.urut', 'asc')
->get();
$gmenu_total = 0;
$dmenu_notif = [];
$user = auth()->user();
foreach ($querydmenu as $d) {
$count = 0;
if ($d->notif) {
if (str_starts_with($d->notif, 'NOTIF:')) {
$keyword = explode(':', $d->notif)[1];
$count = $user->unreadNotifications
->filter(
fn($n) => str_contains(
strtolower(json_encode($n->data)),
strtolower($keyword),
),
)
->count();
} else {
try {
$sql = str_replace(
['{user_id}', '{idroles}', '{id_applicant}', '{idpegawai}'],
[
$user->id,
$user->idroles,
$user->id_applicant ?? 0,
$user->idpegawai ?? 0,
],
$d->notif,
);
$count = DB::select($sql)[0]->notif ?? 0;
} catch (\Exception $e) {
}
}
}
$dmenu_notif[$d->dmenu] = $count;
$gmenu_total += $count;
}
@endphp
-
name == $title_group ? 'aria-expanded=true' : '' }}>
{{ $g->name }}
@if ($gmenu_total > 0)
{{ $gmenu_total }}
@endif
@endif
@endforeach