22 lines
660 B
PHP
22 lines
660 B
PHP
<?php declare(strict_types=1);
|
|
|
|
use BitBadger\PDODocument\Patch;
|
|
use MyPrayerJournal\Domain\{History, RecurrencePeriod, RequestAction};
|
|
use MyPrayerJournal\Table;
|
|
use MyPrayerJournal\UI\Component;
|
|
|
|
require '../../start.php';
|
|
|
|
$req = validate_request($_GET['id'], ['PATCH'], false);
|
|
$now = new DateTimeImmutable('now');
|
|
|
|
array_unshift($req->history, new History($now->format('c'), RequestAction::Prayed));
|
|
$patch = ['history' => $req->history];
|
|
|
|
if ($req->recurrence->period <> RecurrencePeriod::Immediate) {
|
|
$patch['showAfter'] = $now->add($req->recurrence->interval())->format('c');
|
|
}
|
|
Patch::byId(Table::REQUEST, $req->id, $patch);
|
|
|
|
Component::journal();
|