@php // Every item below resolves through the same Gates the route guards use // (registered from ChannelRoleEnum in AuthServiceProvider), so the menu can // never offer a page the guard would answer with 403. $channel = request()->channel; $admin_pages = config('admin.pages'); $admin_groups = config('admin.page_groups'); $curr_page = Route::currentRouteName(); $curr_group = $admin_pages[$curr_page]['page_group'] ?? false; // group the sub menu under main menu $page_groups = []; foreach ($admin_pages as $page_route => $page) { if (!isset($page['page_group'])) { continue; } $page['_route'] = $page_route; $page_groups[$page['page_group']][] = $page; } unset($admin_pages); $fn_showPage = function ($page) use ($channel) { if (!empty($page['hide_menu'])) { return false; } $ability = $page['ability'] ?? null; return $ability === null || Gate::allows($ability, $channel); }; @endphp