Feature/improve domain

This commit is contained in:
Luca Haid
2024-07-30 17:52:04 +00:00
parent 6aebba464f
commit d75f9fa26f
3 changed files with 35 additions and 9 deletions

View File

@@ -106,7 +106,22 @@ class DomainModel {
$rows[] = new DomainModel($row);
}
return $rows;
$newRows = [];
// convert domain contracts to array
$domainContracts = array_map(function ($contract) {
return $contract->toArray();
}, ContractModel::search(['product_id' => 170]));
// search for $domain->domain in $domainContracts['matchcode']
foreach ($rows as $row) {
$contract = array_filter($domainContracts, function ($contract) use ($row) {
return $contract['matchcode'] === $row->domain;
});
$row->contractId = count($contract) > 0 ? array_values($contract)[0]['id'] : null;
$newRows[] = $row;
}
return $newRows;
}
public static function countDomains($filters) {