middleware('auth'); parent::__construct(); } public function index() { return view("profile.index"); } public function update(Request $request) { $request->validate([ 'old_password' => 'required', 'password' => 'required|min:4|confirmed' ]); $user = auth()->user(); // Check if the old password matches the current password if (!Hash::check($request->old_password, $user->password)) { return back()->withErrors(['old_password' => 'Password lama salah']); } // Update the password $user->update([ 'password' => Hash::make($request->password), ]); return back()->with('success', 'Password berhasil diubah'); } }