From 14b4f5c98e1094f402819dd85c59bea0a5df9208 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=B3=B4=EA=B3=A4?= Date: Fri, 20 Feb 2026 09:47:00 +0900 Subject: [PATCH] =?UTF-8?q?fix:=EB=B6=80=EC=84=9C=20=EA=B6=8C=ED=95=9C=20?= =?UTF-8?q?=EA=B4=80=EB=A6=AC=20=EC=A0=84=EC=B2=B4=20=EA=B1=B0=EB=B6=80=20?= =?UTF-8?q?=EB=B2=84=ED=8A=BC=20=EC=A0=9C=EA=B1=B0=20+=20=EC=B4=88?= =?UTF-8?q?=EA=B8=B0=ED=99=94=20deny-all=EB=A1=9C=20=EB=B3=80=EA=B2=BD=20+?= =?UTF-8?q?=20=EB=A1=9C=EB=94=A9=20=EC=98=A4=EB=B2=84=EB=A0=88=EC=9D=B4=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 4.6 --- app/Services/DepartmentPermissionService.php | 42 +++++++++---------- .../department-permissions/index.blade.php | 40 ++++++++++++------ 2 files changed, 46 insertions(+), 36 deletions(-) diff --git a/app/Services/DepartmentPermissionService.php b/app/Services/DepartmentPermissionService.php index 6eb69983..45973e45 100644 --- a/app/Services/DepartmentPermissionService.php +++ b/app/Services/DepartmentPermissionService.php @@ -350,34 +350,30 @@ public function allowAllPermissions(int $departmentId, ?int $tenantId = null, st */ public function denyAllPermissions(int $departmentId, ?int $tenantId = null, string $guardName = 'api'): void { - $query = Menu::where('is_active', 1); + // menu: 접두사를 가진 해당 가드의 모든 권한 ID 조회 + $query = DB::table('permissions') + ->where('guard_name', $guardName) + ->where('name', 'like', 'menu:%'); + if ($tenantId) { $query->where('tenant_id', $tenantId); } - $menus = $query->get(); - foreach ($menus as $menu) { - foreach ($this->permissionTypes as $type) { - $permissionName = "menu:{$menu->id}.{$type}"; - $permission = Permission::where('name', $permissionName) - ->where('guard_name', $guardName) - ->first(); + $permissionIds = $query->pluck('id'); - if ($permission) { - // Soft delete all ALLOW overrides for this department - DB::table('permission_overrides') - ->where('model_type', Department::class) - ->where('model_id', $departmentId) - ->where('permission_id', $permission->id) - ->where('tenant_id', $tenantId) - ->where('effect', 1) - ->whereNull('deleted_at') - ->update([ - 'deleted_at' => now(), - 'deleted_by' => auth()->id(), - ]); - } - } + if ($permissionIds->isNotEmpty()) { + // Soft delete all ALLOW overrides for this department + DB::table('permission_overrides') + ->where('model_type', Department::class) + ->where('model_id', $departmentId) + ->whereIn('permission_id', $permissionIds) + ->where('tenant_id', $tenantId) + ->where('effect', 1) + ->whereNull('deleted_at') + ->update([ + 'deleted_at' => now(), + 'deleted_by' => auth()->id(), + ]); } } diff --git a/resources/views/department-permissions/index.blade.php b/resources/views/department-permissions/index.blade.php index 434f5489..e8237c14 100644 --- a/resources/views/department-permissions/index.blade.php +++ b/resources/views/department-permissions/index.blade.php @@ -53,7 +53,7 @@ class="department-button px-4 py-2 text-sm font-medium rounded-lg border transit - @@ -85,10 +76,21 @@ class="px-4 py-2 bg-gray-500 text-white text-sm font-medium rounded-lg hover:bg- -
+
@include('department-permissions.partials.empty-state')
+ + +