mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/portal.git
synced 2026-08-28 08:54:19 +00:00
WIP Unity Order APIs
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Unity\Processors;
|
||||
|
||||
use Config;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use App\Classes\Modules\Unity\Services\CreatesContractEntity;
|
||||
use App\Classes\Modules\Companies\Services\FetchesCompany;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class CreateContractEntityProcessor
|
||||
{
|
||||
private $createsContractEntity;
|
||||
|
||||
private $fetchesCompany;
|
||||
|
||||
public function __construct(CreatesContractEntity $createsContractEntity, FetchesCompany $fetchesCompany)
|
||||
{
|
||||
$this->createsContractEntity = $createsContractEntity;
|
||||
$this->fetchesCompany = $fetchesCompany;
|
||||
}
|
||||
|
||||
public function execute(Request $request, string $new_contract_id, array $obligations){
|
||||
|
||||
$entity_hash_ids = [];
|
||||
|
||||
$companies = $this->fetchesCompany->getRepository()->whereIn('id',[1, $request->get('warehouse_id')])->get();
|
||||
|
||||
$cief_company = $companies[0]->id == 1 ? $companies[0] : $companies[1];
|
||||
$warehouse_company = $companies[0]->id != 1 ? $companies[0] : $companies[1];
|
||||
|
||||
$entity_hash_ids[] = $cief_company->companyModule()->first()->unity_hash_id;
|
||||
$entity_hash_ids[] = $warehouse_company->companyModule()->first()->unity_hash_id;
|
||||
|
||||
return $this->createsContractEntity->execute($new_contract_id, $entity_hash_ids);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user