If you want the latest of both, unless I'm missing something, you should just be able to query on dateUpdated
.
When you create an entry the first time, its dateUpdated
gets set to the same date as the dateCreated
... So if you query your entries on dateUpdated
only, you will get all entries created + updated in your time frame I guess.
As far as code goes, this should do it:
return [
'endpoints' => [
'entries.json' => function() {
$timeframe = (new \DateTime('1 day ago'))->format(\DateTime::ATOM);
return [
'elementType' => Entry::class,
'criteria' => [
'section' => 'entries',
'dateUpdated' => '>=' . $timeframe,
],
'transformer' => function(Entry $entry) {
return [
'title' => $entry->title,
'url' => $entry->url,
];
},
];
},
]
];