subscribe : fix date saving, duplicate detection and display format
All checks were successful
Deploy / Deploy to Production (push) Successful in 10s
All checks were successful
Deploy / Deploy to Production (push) Successful in 10s
Fix inscription date key to lowercase for Kirby compatibility, fix duplicate email check using array_column, change date display to DD/MM/YYYY, and sort subscribers by inscription date. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
641ddc3fdd
commit
b2139d8f40
2 changed files with 4 additions and 5 deletions
|
|
@ -12,15 +12,14 @@ tabs:
|
||||||
subscribers:
|
subscribers:
|
||||||
label: Abonnés
|
label: Abonnés
|
||||||
type: structure
|
type: structure
|
||||||
sortBy: email asc
|
sortBy: inscriptionDate desc
|
||||||
fields:
|
fields:
|
||||||
email:
|
email:
|
||||||
type: email
|
type: email
|
||||||
inscriptionDate:
|
inscriptionDate:
|
||||||
label: Date d'inscription
|
label: Date d'inscription
|
||||||
type: date
|
type: date
|
||||||
display: MM/DD/YYYY
|
display: DD/MM/YYYY
|
||||||
default: today
|
|
||||||
- width: 1/3
|
- width: 1/3
|
||||||
sections:
|
sections:
|
||||||
newsletters:
|
newsletters:
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ return [
|
||||||
$page = page('lettre');
|
$page = page('lettre');
|
||||||
$subscribers = $page->subscribers()->yaml();
|
$subscribers = $page->subscribers()->yaml();
|
||||||
|
|
||||||
$emailExists = in_array(['email' => $email], $subscribers);
|
$emailExists = in_array($email, array_column($subscribers, 'email'));
|
||||||
|
|
||||||
if ($emailExists) {
|
if ($emailExists) {
|
||||||
return [
|
return [
|
||||||
|
|
@ -24,7 +24,7 @@ return [
|
||||||
|
|
||||||
$newSubscriber = [
|
$newSubscriber = [
|
||||||
'email' => $email,
|
'email' => $email,
|
||||||
'inscriptionDate' => date('Y-m-d')
|
'inscriptiondate' => date('Y-m-d')
|
||||||
];
|
];
|
||||||
$subscribers[] = $newSubscriber;
|
$subscribers[] = $newSubscriber;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue