Hi,
In my blueprint i have a structure
to manipulate and modify from a plugin :
----
Maillingblock:
-
mailobject: My first email
datesent: 2023-11-04
sentdate: ""
-
mailobject: My second email
datesent: 2023-11-11
sentdate: ""
----
Later i’m interested to filter this structure using filterby
to see if today is the day to send a mail
, but in a first time i try to understand how i will update the sentDate
fields with current time.
In the plugin that manage my email campaign with an exemple of filter on DateSent
field :
'action' => function () use ($kirby){
$eventpages = $kirby->site()->pages()->find("evenements")->children();
foreach($eventpages as $event){
$mblocks =$event->Maillingblock()->toStructure();
// update Field if Date is superior to 2023-10-10
$not_empty_block = $mblocks->map(function($x) {
if (V::date($x->content()->DateSent(), '>=', '2023-10-10') ){
$x->content()->update(['SentDate' => time()]);
}
return $x;
});
$event = $event->update(['maillingBlock' => $not_empty_block]);
}
return [$event];
}
I run the plugin, by calling the defined route (http://localhost:8000/evenements/mailling
) but nothing happen in the structure when i refresh the corresponding blueprint page …
I don’t understand well how updating() works, i already read this doc :
Thanks,
SR