user(); $this->name = $user->name; $this->email = $user->email; $this->phone = (string) $user->phone; } public function save(): void { $this->validate([ 'name' => ['required', 'string', 'max:255'], 'email' => ['required', 'email', Rule::unique('users', 'email')->ignore(auth()->id())], 'phone' => ['nullable', 'string', 'max:32'], 'password' => ['nullable', 'string', 'same:password_confirmation', 'min:8'], ]); $user = auth()->user(); $payload = [ 'name' => $this->name, 'email' => $this->email, 'phone' => $this->phone, ]; if ($this->password !== '') { $payload['password'] = Hash::make($this->password); } $user->update($payload); session()->flash('success', 'Профиль обновлен.'); } public function render() { return view('livewire.profile.profile-page')->title('Профиль'); } }