diff --git a/app/Services/Hr/EmployeeService.php b/app/Services/Hr/EmployeeService.php index c967994..8cdc121 100644 --- a/app/Services/Hr/EmployeeService.php +++ b/app/Services/Hr/EmployeeService.php @@ -107,13 +107,16 @@ public function update(User $user, array $validated): void $user->username = $validated['username']; $user->save(); - $profile = $user->profile; - $profile->full_name = $validated['full_name']; - $profile->phone_number = $validated['phone_number']; - $profile->gender = $validated['gender']; - $profile->birth_date = $validated['birth_date']; - $profile->address = $validated['address']; - $profile->save(); + $user->profile()->updateOrCreate( + ['user_id' => $user->id], + [ + 'full_name' => $validated['full_name'], + 'phone_number' => $validated['phone_number'], + 'gender' => $validated['gender'], + 'birth_date' => $validated['birth_date'], + 'address' => $validated['address'], + ], + ); $hasEmployee = ! empty($validated['join_date']) && ! empty($validated['employment_status']) && ! empty($validated['base_salary']);