<?php
namespace Modules\Orders\Details\OrderCompanies; class Model extends \Engine\Mvc\ModelAbstract { protected $idOrder; public function __construct($idOrder) { $this->idOrder = $idOrder; } public function getCompaniesList(): array { $idCorporatesList = \Entity\Order::select($this->idOrder)->idCorporatesList; if ($idCorporatesList) { $listObj = new \App\EntityList\Corporates(); $listObj->setColumns(['alias' => 'name', 'type', 'company', 'companyPrefix', 'companySuffix', 'fiscalCode', 'status']); $listObj->setFilter('id', 'IN', $idCorporatesList); $companiesByKey = []; foreach ($listObj->exportRecords() as $company) { $companiesByKey[$company['id']] = $company; } $companiesList = []; foreach ($idCorporatesList as $id) { if (isset($companiesByKey[$id])) { $companiesList[] = $companiesByKey[$id]; } } return $companiesList; } return []; } } 