validate([ 'name' => ['required', 'string', 'max:255'], 'email' => ['required', 'email', Rule::unique('users')->ignore(Auth::user())], 'password' => ['sometimes', 'nullable', 'confirmed', Password::defaults()], ]); //dd($validated); Auth::user()->update([ 'name' => $validated['name'], 'email' => $validated['email'], ]); if (isset($validated['password'])) { Auth::user()->update([ 'password' => Hash::make($validated['password']), ]); } return redirect()->route('profile.show')->with('success', 'Profile updated.'); } }