user(); return view('guru.profile.edit', compact('guru')); } public function update(Request $request) { $guru = Auth::guard('guru')->user(); $request->validate([ 'password' => 'nullable|min:6|confirmed', 'password_confirmation' => 'nullable', 'foto_profil' => 'nullable|image|mimes:jpg,jpeg,png,webp|max:2048', ], [ 'password.min' => 'Password minimal 6 karakter.', 'password.confirmed' => 'Konfirmasi password tidak cocok.', 'foto_profil.image' => 'File harus berupa gambar.', 'foto_profil.max' => 'Ukuran foto maksimal 2MB.', ]); $data = []; if ($request->filled('password')) { $data['password'] = Hash::make($request->password); } if ($request->hasFile('foto_profil')) { if ($guru->foto_profil && Storage::disk('public')->exists($guru->foto_profil)) { Storage::disk('public')->delete($guru->foto_profil); } $path = $request->file('foto_profil')->store('foto_profil/guru', 'public'); $data['foto_profil'] = $path; } if (!empty($data)) { $guru->update($data); } return redirect()->route('guru.profile.edit') ->with('success', 'Profil berhasil diperbarui!'); } }