mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-19 20:43:56 +00:00
51 lines
1.5 KiB
PHP
51 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace App\Classes\Modules\Contacts\Processors;
|
|
|
|
use App\Classes\Modules\Contacts\DataTransferObjects\ContactObject;
|
|
use App\Classes\Modules\Contacts\Services\CreatesContact;
|
|
use App\Classes\Modules\Contacts\Standards\Rules\CanCreateContact;
|
|
use App\Models\Company;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class CreateContactProcessor
|
|
{
|
|
|
|
/** @var CanCreateContact */
|
|
private $canCreateContact;
|
|
|
|
/** @var CreatesContact */
|
|
private $createsContact;
|
|
|
|
/**
|
|
* CreateContactProcessor constructor.
|
|
* @param CanCreateContact $canCreateContact
|
|
* @param CreatesContact $createsContact
|
|
*/
|
|
public function __construct(CanCreateContact $canCreateContact, CreatesContact $createsContact)
|
|
{
|
|
$this->canCreateContact = $canCreateContact;
|
|
$this->createsContact = $createsContact;
|
|
}
|
|
|
|
/**
|
|
* @param Request $request
|
|
* @param Company $company
|
|
* @return Model
|
|
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
|
* @throws \App\Classes\Exceptions\MalformedRequestException
|
|
* @throws \App\Classes\Exceptions\RequestValidationException
|
|
*/
|
|
public function execute(Request $request, Company $company): Model {
|
|
|
|
$contact_object = new ContactObject($company->id, $request->input('name'),
|
|
$request->input('phone'), $request->input('contact_email'), $request->input('wechat_id'));
|
|
|
|
$this->canCreateContact->passes($contact_object);
|
|
|
|
return $this->createsContact->execute($contact_object);
|
|
|
|
}
|
|
|
|
} |