name = Auth::user()->name; $this->email = Auth::user()->email; $this->preferred_username = Auth::user()->preferred_username; $this->avatar = Auth::user()->avatar; $this->auto_approve_apps = Auth::user()->auto_approve_apps; } /** * Update the profile information for the currently authenticated user. */ public function updateProfileInformation(): void { $user = Auth::user(); $validated = $this->validate([ 'name' => 'required|string|max:255', 'email' => [ 'required', 'string', 'lowercase', 'email', 'max:255', Rule::unique(User::class)->ignore($user->id), ], 'preferred_username' => 'string|max:255', 'auto_approve_apps' => 'boolean' ]); $user->fill($validated); if (!empty($this->avatarUpload)) { if (!empty($user->avatar)) { Storage::disk('avatars')->delete($user->avatar); } $user->avatar = $this->avatarUpload->store(options: 'avatars'); } $user->save(); $this->dispatch('profile-updated', name: $user->name); } public function updatePassword(): void { try { $validated = $this->validate([ 'current_password' => ['required', 'string', 'current_password'], 'password' => ['required', 'string', PasswordRule::defaults(), 'confirmed'], ]); } catch (ValidationException $e) { $this->reset('current_password', 'password', 'password_confirmation'); throw $e; } Auth::user()->update([ 'password' => Hash::make($validated['password']), ]); $this->reset('current_password', 'password', 'password_confirmation'); $this->dispatch('password-updated'); } public function render() { return view('livewire.forms.user-profile'); } }