dwdwf
This commit is contained in:
parent
5ddca35389
commit
96473fd60b
|
|
@ -3170,9 +3170,18 @@ private function upsertAddress(int $personId, array $addrData, $mappings): array
|
||||||
$data['person_id'] = $personId;
|
$data['person_id'] = $personId;
|
||||||
$data['country'] = $data['country'] ?? 'SLO';
|
$data['country'] = $data['country'] ?? 'SLO';
|
||||||
$data['type_id'] = $data['type_id'] ?? $this->getDefaultAddressTypeId();
|
$data['type_id'] = $data['type_id'] ?? $this->getDefaultAddressTypeId();
|
||||||
|
try {
|
||||||
$created = PersonAddress::create($data);
|
$created = PersonAddress::create($data);
|
||||||
|
|
||||||
return ['action' => 'inserted', 'address' => $created];
|
return ['action' => 'inserted', 'address' => $created];
|
||||||
|
} catch (QueryException $e) {
|
||||||
|
// If unique constraint violation, skip instead of aborting
|
||||||
|
if ($e->getCode() === '23505' || str_contains($e->getMessage(), 'unique') || str_contains($e->getMessage(), 'duplicate')) {
|
||||||
|
return ['action' => 'skipped', 'message' => 'Address already exists (constraint violation)'];
|
||||||
|
}
|
||||||
|
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user