From ba24034020cfd43584e1ab70c1f8a1676eb70bce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=B3=B4=EA=B3=A4?= Date: Thu, 26 Feb 2026 16:53:32 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20[hr]=20=EC=82=AC=EC=9B=90=20=EB=93=B1?= =?UTF-8?q?=EB=A1=9D=20=EC=8B=9C=20user=5Ftenants=20pivot=20=EC=97=B0?= =?UTF-8?q?=EB=8F=99=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - User 생성 후 tenants()->attach() 호출 (멀티테넌트 필수) - user_id, must_change_password, created_by 필드 추가 - 기존 UserService 패턴과 동일하게 맞춤 --- app/Services/HR/EmployeeService.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/app/Services/HR/EmployeeService.php b/app/Services/HR/EmployeeService.php index 42441d5a..d0afbc7a 100644 --- a/app/Services/HR/EmployeeService.php +++ b/app/Services/HR/EmployeeService.php @@ -93,13 +93,25 @@ public function createEmployee(array $data): Employee return DB::transaction(function () use ($data, $tenantId) { // User 생성 $user = User::create([ + 'user_id' => $data['email'] ?? $data['name'], 'name' => $data['name'], 'email' => $data['email'] ?? null, 'phone' => $data['phone'] ?? null, 'password' => bcrypt($data['password'] ?? 'sam1234!'), 'is_active' => true, + 'must_change_password' => true, + 'created_by' => auth()->id(), ]); + // user_tenants pivot 연동 (멀티테넌트 필수) + if ($tenantId) { + $user->tenants()->attach($tenantId, [ + 'is_active' => true, + 'is_default' => true, + 'joined_at' => now(), + ]); + } + // json_extra 구성 $jsonExtra = []; if (! empty($data['employee_code'])) {