WIP Unity Order APIs

This commit is contained in:
Fairuz
2021-08-02 11:48:29 +08:00
parent 2ad01a4195
commit 58d8367bc7
5 changed files with 87 additions and 7 deletions
@@ -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);
}
}