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'])) {