white-paper : track downloaded page per contact - refs #70
All checks were successful
Deploy / Deploy to Production (push) Successful in 21s

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
isUnknown 2026-04-22 13:29:44 +02:00
parent 77c4a06b30
commit 0ca55bed5d
2 changed files with 18 additions and 0 deletions

View file

@ -60,6 +60,8 @@ return [
}
}
$pageUuid = $page->uuid()->toString();
if ($existingIndex !== null) {
// Contact déjà présent — on enrichit les champs vides uniquement
if ($company !== '' && empty($entries[$existingIndex]['company'])) {
@ -68,6 +70,14 @@ return [
if ($role !== '' && empty($entries[$existingIndex]['role'])) {
$entries[$existingIndex]['role'] = $role;
}
$whitePapers = $entries[$existingIndex]['whitepaper'] ?? [];
if (!is_array($whitePapers)) {
$whitePapers = array_filter(array_map('trim', explode(',', (string) $whitePapers)));
}
if (!in_array($pageUuid, $whitePapers, true)) {
$whitePapers[] = $pageUuid;
}
$entries[$existingIndex]['whitePaper'] = $whitePapers;
} else {
$entries[] = [
'firstName' => $firstName,
@ -75,6 +85,7 @@ return [
'email' => $email,
'company' => $company,
'role' => $role,
'whitePaper' => [$pageUuid],
'downloadedAt' => date('d/m/Y H:i'),
];
}