mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal.git
synced 2026-08-19 04:24:12 +00:00
update: changes on Contacts Module based on changes #6
This commit is contained in:
@@ -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;
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
// /**
|
||||
// * @return string
|
||||
// */
|
||||
// public function getOwnerType(): string
|
||||
// {
|
||||
// return $this->owner_type;
|
||||
// }
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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' => '',
|
||||
|
||||
Reference in New Issue
Block a user