fix: sync employee photo to user profile avatar, topbar, and dashboard

This commit is contained in:
Ray1111-aa
2026-10-20 19:22:28 +07:00
parent 7126648c1c
commit cd3ce0c191
10 changed files with 424 additions and 49 deletions
@@ -568,6 +568,7 @@ class EmployeeController extends Controller
$photoPath = null;
if ($request->hasFile('photo')) {
$photoPath = ImageCompressionService::uploadAndCompress($request->file('photo'), 'employees', 500, 500, 80);
$user->update(['photo_path' => $photoPath]);
}
Employee::create([
@@ -627,6 +628,18 @@ class EmployeeController extends Controller
'photo_path' => $photoPath,
]);
// Sinkronkan akun login User terkait
$linkedUser = $employee->user ?: User::where('username', $employee->nik)->first();
if ($linkedUser) {
if (!$employee->user_id) {
$employee->update(['user_id' => $linkedUser->id]);
}
$linkedUser->update([
'name' => $employee->name,
'photo_path' => $photoPath,
]);
}
return back()->with('success', "Data SIMPER untuk {$employee->name} berhasil diperbarui.");
}
}