From 5ae52c5a914303a1e2eed31b39f9f1d663286bd8 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Tue, 24 Jan 2023 07:42:15 +1100 Subject: [PATCH] If not contacts array is passed, do no attempt to modify / save contacts --- app/Repositories/ClientRepository.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/Repositories/ClientRepository.php b/app/Repositories/ClientRepository.php index 004eece6e6be..0e78a3d49207 100644 --- a/app/Repositories/ClientRepository.php +++ b/app/Repositories/ClientRepository.php @@ -102,7 +102,9 @@ class ClientRepository extends BaseRepository $data['name'] = $client->present()->name(); } - if(array_key_exists('contacts', $contact_data)) + //24-01-2023 when a logo is uploaded, no other data is set, so we need to catch here and not update + //the contacts array UNLESS there are no contacts and we need to maintain state. + if(array_key_exists('contacts', $contact_data) || $client->contacts()->count() == 0) $this->contact_repo->save($contact_data, $client); return $client;