Files
portal/app/Classes/Modules/Companies/Services/CreatesCompanyConnection.php
T
omair saleh d8c767c670 Large commit
2021-08-16 08:59:43 +08:00

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);
}
}