From 7b2c65ac9aaea480d6da00c60a7e198b3172446f Mon Sep 17 00:00:00 2001 From: mahdahar <89adham@gmail.com> Date: Fri, 17 Apr 2026 09:57:13 +0700 Subject: [PATCH] fix : contact detail not processed --- app/Helpers/utc_helper.php | 16 ++++++++-------- app/Models/Contact/ContactModel.php | 8 ++++++-- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/app/Helpers/utc_helper.php b/app/Helpers/utc_helper.php index c51e61a..bb082ac 100755 --- a/app/Helpers/utc_helper.php +++ b/app/Helpers/utc_helper.php @@ -22,14 +22,14 @@ if (!function_exists('convert_array_to_utc')) { } } -if (!function_exists('is_datetime_string')) { - function is_datetime_string(string $value): bool { - return preg_match( - '/^\d{4}-\d{2}-\d{2}(?:[T\s]\d{2}:\d{2}:\d{2}(?:[\+\-]\d{2}:?\d{2}|Z)?)?$/', - $value - ) === 1; - } -} +if (!function_exists('is_datetime_string')) { + function is_datetime_string(string $value): bool { + return preg_match( + '/^\d{4}-\d{2}-\d{2}(?:[T\s]\d{2}:\d{2}:\d{2}(?:\.\d{1,6})?(?:[\+\-]\d{2}:?\d{2}|Z)?)?$/', + $value + ) === 1; + } +} if (!function_exists('convert_array_to_utc_iso')) { function convert_array_to_utc_iso($data) { diff --git a/app/Models/Contact/ContactModel.php b/app/Models/Contact/ContactModel.php index fbfb76e..767498b 100755 --- a/app/Models/Contact/ContactModel.php +++ b/app/Models/Contact/ContactModel.php @@ -86,12 +86,16 @@ class ContactModel extends BaseModel { $details = $data['Details'] ?? []; unset($data['Details']); + $contactData = array_intersect_key($data, array_flip($this->allowedFields)); + if (!empty($data['ContactID'])) { $contactId = $data['ContactID']; - $this->update($contactId, $data); + if (!empty($contactData)) { + $this->update($contactId, $contactData); + } } else { $contactId = $this->insert($data, true); - } + } if (!$contactId) { throw new \RuntimeException('Failed to save contact');