diff --git a/app/Classes/Modules/Contacts/DataTransferObjects/ContactObject.php b/app/Classes/Modules/Contacts/DataTransferObjects/ContactObject.php index f408d8cc..ac512cd1 100644 --- a/app/Classes/Modules/Contacts/DataTransferObjects/ContactObject.php +++ b/app/Classes/Modules/Contacts/DataTransferObjects/ContactObject.php @@ -22,9 +22,6 @@ class ContactObject implements DataTransferObject /** @var string|null */ private $wechat_id; - /** @var int|null */ - private $countryId; - /** * ContactObject constructor. * @param int $companyId @@ -34,22 +31,12 @@ class ContactObject implements DataTransferObject * @param null|string $wechat_id * @param int|null $countryId */ - public function __construct(int $companyId, string $reference, ?string $phone, ?string $email, ?string $wechat_id, ?int $countryId = Countries::MALAYSIA) + public function __construct(string $reference, ?string $phone, ?string $email, ?string $wechat_id) { - $this->companyId = $companyId; $this->reference = $reference; $this->phone = $phone; $this->email = $email; $this->wechat_id = $wechat_id; - $this->countryId = $countryId; - } - - /** - * @return int - */ - public function getCompanyId(): int - { - return $this->companyId; } /** @@ -84,15 +71,19 @@ class ContactObject implements DataTransferObject return $this->wechat_id; } - /** - * @return int - */ - public function getCountryId(): int - { - return $this->countryId; - } + // /** + // * @return int + // */ + // public function getOwnerId(): int + // { + // return $this->owner_id; + // } - - - -} \ No newline at end of file + // /** + // * @return string + // */ + // public function getOwnerType(): string + // { + // return $this->owner_type; + // } +} diff --git a/app/Classes/Modules/Contacts/Processors/CreateContactProcessor.php b/app/Classes/Modules/Contacts/Processors/CreateContactProcessor.php index 5373c84f..e499878c 100644 --- a/app/Classes/Modules/Contacts/Processors/CreateContactProcessor.php +++ b/app/Classes/Modules/Contacts/Processors/CreateContactProcessor.php @@ -15,9 +15,6 @@ class CreateContactProcessor /** @var CanCreateContact */ private $canCreateContact; - /** @var CreatesContact */ - private $createsContact; - /** * CreateContactProcessor constructor. * @param CanCreateContact $canCreateContact @@ -41,15 +38,14 @@ class CreateContactProcessor { $contact_object = new ContactObject( - $company->id, $request->input('name'), $request->input('phone'), $request->input('contact_email'), - $request->input('wechat_id') + $request->input('wechat_id'), ); $this->canCreateContact->passes($contact_object); - return $this->createsContact->execute($contact_object); + return $this->createsContact->execute($company,$contact_object); } } diff --git a/app/Classes/Modules/Contacts/Services/CreatesContact.php b/app/Classes/Modules/Contacts/Services/CreatesContact.php index 1ba4a8d3..08492883 100644 --- a/app/Classes/Modules/Contacts/Services/CreatesContact.php +++ b/app/Classes/Modules/Contacts/Services/CreatesContact.php @@ -3,26 +3,27 @@ namespace App\Classes\Modules\Contacts\Services; use App\Classes\General\Eloquent\AbstractUpdateRecord; +use App\Classes\General\Interfaces\Contactable; +use App\Classes\General\Eloquent\AbstractUpdateRelationshipRecord; use App\Classes\Modules\Contacts\DataTransferObjects\ContactObject; use App\Models\Contact; -class CreatesContact extends AbstractUpdateRecord +class CreatesContact extends AbstractUpdateRelationshipRecord { /** + * @param Contactable $contactable * @param ContactObject $object * @return \Illuminate\Database\Eloquent\Model * @throws \App\Classes\Exceptions\MalformedRequestException */ - public function execute(ContactObject $object) + public function execute(Contactable $contactable, ContactObject $object) { $model = new Contact(); - $model->country_id = $object->getCountryId(); - $model->company_id = $object->getCompanyId(); $model->reference = $object->getReference(); $model->phone = $object->getPhone(); $model->email = $object->getEmail(); $model->wechat_id = $object->getWechatId(); - return $this->handler($model); + return $this->handler($contactable->contacts(), $model); } } diff --git a/app/Classes/Modules/Contacts/Standards/Validators/ContactValidation.php b/app/Classes/Modules/Contacts/Standards/Validators/ContactValidation.php index ee735985..ac02109a 100644 --- a/app/Classes/Modules/Contacts/Standards/Validators/ContactValidation.php +++ b/app/Classes/Modules/Contacts/Standards/Validators/ContactValidation.php @@ -14,8 +14,6 @@ class ContactValidation extends AbstractValidation protected function data($object): array { return [ - 'country_id' => $object->getCountryId(), - 'company_id' => $object->getCompanyId(), 'contact_reference' => $object->getReference(), 'phone' => $object->getPhone(), 'contact_email' => $object->getEmail(), @@ -29,8 +27,6 @@ class ContactValidation extends AbstractValidation protected function rules(): array { return [ - 'country_id' => 'required', - 'company_id' => 'required', 'contact_reference' => '', 'phone' => 'required', 'contact_email' => '',