'required', 'email' => 'required', 'password' => 'required' ]; protected $messages = [ 'name.required' => 'Il nome è obbligatorio', 'email.required' => 'La mail è obbligatoria', 'password.required' => 'La password è obbligatoria', ]; public function resetFields(){ $this->name = ''; $this->email = ''; $this->password = ''; $this->newPassword = ''; } public function render() { $this->name = \Auth::user()->name; $this->email = \Auth::user()->email; return view('livewire.profile'); } public function edit() { $this->resetFields(); $this->update = true; } public function save() { $this->validate(); try { $user = \Auth::user(); $user->name = $this->name; $user->email = $this->email; if ($this->password != '') { $user->password = bcrypt($this->password); } $user->save(); session()->flash('success','Dato creato'); $this->resetFields(); $this->update = false; } catch (\Exception $ex) { session()->flash('error','Errore (' . $ex->getMessage() . ')'); } } }