id) ->orWhere('customer_email', $user->email) ->with('items') ->latest() ->get(); $communications = collect(); if (Schema::hasTable('communications')) { $communications = Communication::where('user_id', $user->id) ->orWhere('email', strtolower($user->email)) ->with('replies') ->latest() ->get(); } return view('account.index', compact('user', 'orders', 'communications')); } /** * Update customer profile info. */ public function updateProfile(Request $request): RedirectResponse { $user = Auth::user(); $validated = $request->validate([ 'name' => 'required|string|max:255', 'email' => ['required', 'email', 'max:255', Rule::unique('users')->ignore($user->id)], ]); $user->update($validated); return back()->with('success', 'Jouw profielgegevens zijn succesvol bijgewerkt.'); } /** * Update customer password. */ public function updatePassword(Request $request): RedirectResponse { $user = Auth::user(); $validated = $request->validate([ 'current_password' => 'required|current_password', 'password' => 'required|string|min:8|confirmed', ], [ 'current_password.current_password' => 'Het huidige wachtwoord is onjuist.', 'password.min' => 'Het nieuwe wachtwoord moet minimaal 8 tekens lang zijn.', 'password.confirmed' => 'De nieuwe wachtwoorden komen niet met elkaar overeen.', ]); $user->update([ 'password' => Hash::make($validated['password']), ]); return back()->with('success', 'Jouw wachtwoord is succesvol gewijzigd.'); } }