validate([ 'currentPassword' => 'required|string', 'newPassword' => 'required|string', 'newPasswordConfirmation' => 'required|string', ]); if (! Hash::check($this->currentPassword, auth()->user()->password)) { $this->addError('currentPassword', __('admin_settings.password_wrong')); return; } try { app(UpdateUserPassword::class)->update(auth()->user(), [ 'current_password' => $this->currentPassword, 'password' => $this->newPassword, 'password_confirmation' => $this->newPasswordConfirmation, ]); } catch (ValidationException $e) { foreach ($e->errors() as $field => $messages) { $this->addError(match ($field) { 'current_password' => 'currentPassword', 'password' => 'newPassword', default => $field, }, $messages[0]); } return; } $this->reset('currentPassword', 'newPassword', 'newPasswordConfirmation'); $this->dispatch('notify', message: __('admin_settings.password_changed')); } }