['required', 'string', 'min:3', 'max:40', Rule::unique('users')->ignore($user->id)], 'email' => ['required', 'email', 'max:40', Rule::unique('users')->ignore($user->id)], 'photo' => ['nullable', 'mimes:jpg,jpeg,png,svg', 'max:1024'], ])->validateWithBag('updateProfileInformation'); if (isset($input['photo'])) { $user->updateProfilePhoto($input['photo']); } else { $user->forcefill(['profile_photo_path' => timebank_config('profiles.user.profile_photo_path_default')])->save(); } if ($input['email'] !== $user->email && $user instanceof MustVerifyEmail) { $this->updateVerifiedUser($user, $input); } else { $user->forceFill([ 'email' => $input['email'], ])->save(); // Also update session with new name and profile_photo_path Session([ 'activeProfileName' => Auth::user()->name, 'activeProfilePhoto' => Auth::user()->profile_photo_path ]); return redirect()->route('profile.show_by_type_and_id'); } } /** * Update the given verified user's profile information. * * @param mixed $user * @param array $input * @return void */ protected function updateVerifiedUser($user, array $input) { $user->forceFill([ 'name' => $input['name'], 'email' => $input['email'], 'email_verified_at' => null, ])->save(); $user->sendEmailVerificationNotification(); } }