refactor: streamline user profile update process by replacing individual field assignments with updateOrCreate method

This commit is contained in:
Yoga Pangestu 2026-06-19 13:58:11 +07:00
parent 55b779c76e
commit 5b7da76fc8

View File

@ -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']);