mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/portal.git
synced 2026-08-20 04:53:59 +00:00
52 lines
1.5 KiB
PHP
52 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;
|
|
|
|
/**
|
|
* 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(
|
|
$request->input('name'),
|
|
$request->input('phone'),
|
|
$request->input('contact_email'),
|
|
$request->input('wechat_id'),
|
|
);
|
|
|
|
$this->canCreateContact->passes($contact_object);
|
|
|
|
return $this->createsContact->execute($company,$contact_object);
|
|
}
|
|
}
|