big update all menus

This commit is contained in:
Wian Drs
2026-08-07 09:16:13 +07:00
parent 75342dc7b7
commit e7575ba1c0
101 changed files with 3451 additions and 89 deletions
+8 -3
View File
@@ -22,7 +22,9 @@ class MenuController extends ApiController
if ($user->isMasterAdmin() || $user->is_platform_staff) {
$menus = MenuList::query()
->where('is_active', true)
->when($user->is_platform_staff && ! $user->isMasterAdmin(), fn ($q) => $q->whereIn('slug', ['role-applications', 'role-applications-tenants']))
->when($user->is_platform_staff && ! $user->isMasterAdmin(), fn ($q) => $q->whereIn('slug', [
'role-applications', 'role-applications-tenants', 'nas', 'nas-script-policies',
]))
->orderBy('sort_order')
->orderBy('id')
->get()
@@ -42,6 +44,7 @@ class MenuController extends ApiController
'can_update' => true,
'can_delete' => true,
'can_approve' => true,
'can_activate' => true,
'can_export' => true,
],
];
@@ -80,13 +83,14 @@ class MenuController extends ApiController
DB::raw('MAX(CASE WHEN mgm.can_update THEN 1 ELSE 0 END) as can_update'),
DB::raw('MAX(CASE WHEN mgm.can_delete THEN 1 ELSE 0 END) as can_delete'),
DB::raw('MAX(CASE WHEN mgm.can_approve THEN 1 ELSE 0 END) as can_approve'),
DB::raw('MAX(CASE WHEN mgm.can_activate THEN 1 ELSE 0 END) as can_activate'),
DB::raw('MAX(CASE WHEN mgm.can_export THEN 1 ELSE 0 END) as can_export')
)
->orderBy('m.sort_order')
->orderBy('m.id')
->get();
$menus = $menuRows->map(function ($row) {
$menus = $menuRows->map(function ($row) use ($tenantRole) {
return [
'id' => (int) $row->id,
'parent_id' => $row->parent_id ? (int) $row->parent_id : null,
@@ -102,6 +106,7 @@ class MenuController extends ApiController
'can_update' => (bool) $row->can_update,
'can_delete' => (bool) $row->can_delete,
'can_approve' => (bool) $row->can_approve,
'can_activate' => $tenantRole === 'tenant_owner' || (bool) $row->can_activate,
'can_export' => (bool) $row->can_export,
],
];
@@ -115,7 +120,7 @@ class MenuController extends ApiController
$tree = $this->removeRestrictedMenus($tree, $restrictedSlugs);
}
if (! $user->isMasterAdmin() && ! $user->is_platform_staff) {
$tree = $this->removeRestrictedMenus($tree, ['role-applications-tenants']);
$tree = $this->removeRestrictedMenus($tree, ['role-applications-tenants', 'nas-script-policies', 'nas-radius-infrastructure']);
}
if (! $user->isTenantOwner($tenantId)) {
$tree = $this->removeRestrictedMenus($tree, ['role-applications-staff']);