From ddc9df66503b6bb57df1cf397667994daf6dbda1 Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Mon, 27 Mar 2017 11:36:48 +0300 Subject: [PATCH] Fixes for contact API --- app/Http/Controllers/ContactApiController.php | 2 +- app/Ninja/Repositories/ContactRepository.php | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/app/Http/Controllers/ContactApiController.php b/app/Http/Controllers/ContactApiController.php index fd388bd34b..a74658077f 100644 --- a/app/Http/Controllers/ContactApiController.php +++ b/app/Http/Controllers/ContactApiController.php @@ -144,7 +144,7 @@ class ContactApiController extends BaseAPIController $data = $request->input(); $data['public_id'] = $publicId; - $expense = $this->contactService->save($data, $request->entity()); + $contact = $this->contactService->save($data, $request->entity()); return $this->itemResponse($contact); } diff --git a/app/Ninja/Repositories/ContactRepository.php b/app/Ninja/Repositories/ContactRepository.php index 51a30bec46..878e1263a0 100644 --- a/app/Ninja/Repositories/ContactRepository.php +++ b/app/Ninja/Repositories/ContactRepository.php @@ -6,11 +6,13 @@ use App\Models\Contact; class ContactRepository extends BaseRepository { - public function save($data) + public function save($data, $contact = false) { $publicId = isset($data['public_id']) ? $data['public_id'] : false; - if (! $publicId || $publicId == '-1') { + if ($contact) { + // do nothing + } elseif (! $publicId || $publicId == '-1') { $contact = Contact::createNew(); $contact->send_invoice = true; $contact->client_id = $data['client_id'];