mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/portal.git
synced 2026-08-20 04:53:59 +00:00
45 lines
1.2 KiB
PHP
45 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Classes\Modules\Companies\Services;
|
|
|
|
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
|
use App\Classes\Modules\Companies\DataTransferObjects\CompanyConnectionObject;
|
|
use App\Models\CompanyConnection;
|
|
|
|
class CreatesCompanyConnection extends AbstractUpdateRecord
|
|
{
|
|
|
|
/** @var FetchesCompany */
|
|
private $fetchesCompany;
|
|
|
|
/**
|
|
* CreatesCompanyConnection constructor.
|
|
* @param FetchesCompany $fetchesCompany
|
|
*/
|
|
public function __construct(FetchesCompany $fetchesCompany)
|
|
{
|
|
$this->fetchesCompany = $fetchesCompany;
|
|
}
|
|
|
|
|
|
/**
|
|
* @param CompanyConnectionObject $object
|
|
* @return mixed
|
|
* @throws \App\Classes\Exceptions\MalformedRequestException
|
|
*/
|
|
public function execute(CompanyConnectionObject $object)
|
|
{
|
|
|
|
$companyModule = $this->fetchesCompany->execute(['id', 1])->companyModules()->first();
|
|
|
|
$connection = new CompanyConnection();
|
|
$connection->inviter_id = $companyModule->id;
|
|
$connection->invitee_id = $object->getInvitee()->id;
|
|
$connection->inviter_reference = $object->getInviterReference();
|
|
$connection->invitee_reference = $object->getInviteeReference();
|
|
|
|
return $this->handler($connection);
|
|
|
|
}
|
|
}
|