From 54e5aa28bd4afbc58819137df813d92d8f6bf87e Mon Sep 17 00:00:00 2001 From: FreeScout Date: Thu, 21 Dec 2023 00:55:22 -0800 Subject: [PATCH] Do not set customer last name when it was manually removed - closes #3622 --- app/Customer.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/Customer.php b/app/Customer.php index a4abf9621..3d1c737d8 100644 --- a/app/Customer.php +++ b/app/Customer.php @@ -1013,6 +1013,14 @@ public function setData($data, $replace_data = true, $save = false) $result = true; } else { // Update empty fields. + + // Do not set last name if first name is already set (and vise versa). + if (!empty($this->first_name) && !empty($data['last_name'])) { + unset($data['last_name']); + } + if (!empty($this->last_name) && !empty($data['first_name'])) { + unset($data['first_name']); + } foreach ($data as $key => $value) { if (in_array($key, $this->fillable) && empty($this->$key)) { $this->$key = $value;