mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/izyim.git
synced 2026-08-19 12:34:03 +00:00
42 lines
1.2 KiB
PHP
42 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Modules\ControllerLogic\Contacts;
|
|
|
|
|
|
use App\Classes\Constants;
|
|
use App\Classes\Modules\Contacts\Exceptions\CannotCreateContactException;
|
|
use App\Classes\Modules\ControllerLogic\Exceptions\InternalServerErrorException;
|
|
use App\Modules\Contacts\DataTransferObjects\ContactObject;
|
|
use App\Modules\Contacts\Services\CreatesContact;
|
|
use Illuminate\Http\Request;
|
|
|
|
class CreateContactLogic
|
|
{
|
|
|
|
/** @var CreatesContact */
|
|
private $createsContact;
|
|
|
|
/**
|
|
* CreateContactLogic constructor.
|
|
* @param CreatesContact $createsContact
|
|
*/
|
|
public function __construct(CreatesContact $createsContact)
|
|
{
|
|
$this->createsContact = $createsContact;
|
|
}
|
|
|
|
|
|
public function execute(int $type, int $referenceId, Request $request){
|
|
|
|
try {
|
|
$object = new ContactObject($type, $referenceId, $request->input('name'), $request->input('designation'), $request->input('contact'), $request->input('email'));
|
|
|
|
return $this->createsContact->execute($object);
|
|
} catch (CannotCreateContactException $exception){
|
|
throw new InternalServerErrorException("Failed to create contact because {$exception->getMessage()}");
|
|
}
|
|
|
|
|
|
}
|
|
|
|
} |