From 0f01c100d63ce179bd7d58f81d27377b63cef903 Mon Sep 17 00:00:00 2001 From: hskwon Date: Wed, 20 Aug 2025 11:02:46 +0900 Subject: [PATCH] =?UTF-8?q?fix=20:=20=EB=82=B4=20=ED=85=8C=EB=84=8C?= =?UTF-8?q?=ED=8A=B8=20=EB=AA=A9=EB=A1=9D=20-=20=EC=98=A4=EB=A5=98=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 회원 가입후 테넌트가 없는 상태일때 빈 배열 처리 --- app/Services/TenantService.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/app/Services/TenantService.php b/app/Services/TenantService.php index 2c0b2da..6802546 100644 --- a/app/Services/TenantService.php +++ b/app/Services/TenantService.php @@ -154,6 +154,20 @@ public function generateTenantCode(string $tenantName): string */ public static function getTenants(array $params = []) { + $tenantId = $params['tenant_id'] ?? app('tenant_id'); + + if (!$tenantId) { + // 현재 사용자 기본 테넌트 조회 + $apiUser = app('api_user'); + $userTenant = UserTenant::where('user_id', $apiUser) + ->where('is_default', 1) + ->first(); + + if (!$userTenant) { + return ['error' => '활성(기본) 테넌트를 찾을 수 없습니다.', 'code' => 404]; + } + $tenantId = $userTenant->tenant_id; + } $pageNo = isset($params['page']) ? (int)$params['page'] : 1; $pageSize = isset($params['size']) ? (int)$params['size'] : 10;