update contact recode and clean up

This commit is contained in:
hazim
2019-03-07 16:33:28 +08:00
parent 6e21b42ef9
commit bfda0d8596
@@ -3,6 +3,7 @@
namespace App\Classes\Modules\Contacts\Services;
use App\Classes\Modules\Contacts\Exceptions\CannotCreateContactException;
use App\Models\Contact;
use App\Classes\Modules\Contacts\DataTransferObjects\ContactObject;
@@ -28,16 +29,22 @@ class CreatesContact
*/
public function execute(ContactObject $contact, int $type, int $referenceId)
{
$this->repository->type = $type;
$this->repository->reference_id = $referenceId;
$this->repository->name = $contact->getName();
$this->repository->designation = $contact->getDesignation();
$this->repository->email = $contact->getEmail();
$this->repository->contact = $contact->getContact();
try{
$this->repository->save();
$this->repository->type = $type;
$this->repository->reference_id = $Id;
$this->repository->name = $contact->getName();
$this->repository->designation = $contact->getDesignation();
$this->repository->email = $contact->getEmail();
$this->repository->contact = $contact->getContact();
$this->repository->save();
return $this->repository;
}
catch (\Exception $exception)
{
throw new CannotCreateContactException($exception->getMessage());
}
return $this->repository;
}
}