summaryrefslogtreecommitdiff
path: root/src/Controller/Event.php
diff options
context:
space:
mode:
authorDaniel Weipert <code@drogueronin.de>2023-11-29 11:03:15 +0100
committerDaniel Weipert <code@drogueronin.de>2023-11-29 11:03:15 +0100
commitfa9096c0ab521aae45cab6c48a54290d14a221b9 (patch)
tree61466b792c2714848cfea00594456ac06c259c94 /src/Controller/Event.php
parent3afcaef927391db23fe23c6c8c26b8960e8dae32 (diff)
event tables
Diffstat (limited to 'src/Controller/Event.php')
-rw-r--r--src/Controller/Event.php23
1 files changed, 13 insertions, 10 deletions
diff --git a/src/Controller/Event.php b/src/Controller/Event.php
index a6538fe..78de9d5 100644
--- a/src/Controller/Event.php
+++ b/src/Controller/Event.php
@@ -4,6 +4,7 @@ namespace App\Controller;
use App\DB;
use App\Model\Event as Model;
+use App\Model\Event\SendUnits;
use App\Model\Village;
use App\Router;
use Symfony\Component\HttpFoundation\RedirectResponse;
@@ -31,22 +32,24 @@ class Event
$village = Village::get($event->villageId);
if ($event->type === 'SendUnits') {
- $payload = json_decode($event->payload, true);
+ /**@var SendUnits $sendUnitsEvent*/
+ $sendUnitsEvent = DB::fetch(SendUnits::class, 'select * from events_send_units where event_id=:id', ['id' => $event->id]);
- if ($payload['type'] === 'SendBack') {
+ if ($sendUnitsEvent->type === 'SendBack') {
$cancelTimeDiff = $event->createdAt->diff(new \DateTime());
$cancelTime = (new \DateTime())->add($cancelTimeDiff);
- $cancelPayload = array_replace_recursive($payload, [
- 'cancel' => [
- 'home' => $payload['destination'],
- 'residence' => $payload['source'],
- ],
- ]);
+ $sendUnitsEvent->isCanceled = true;
+ $sendUnitsEvent->home = $sendUnitsEvent->destination;
+ $sendUnitsEvent->residence = $sendUnitsEvent->source;
DB::query(
- 'update events set time=:time, payload=:payload where id=:id',
- ['time' => $cancelTime->format('c'), 'payload' => json_encode($cancelPayload), 'id' => $request->get('id')]
+ 'update events set time=:time, where id=:id',
+ ['time' => $cancelTime->format('c'), 'id' => $request->get('id')]
+ );
+ DB::query(
+ 'update events_send_units set is_canceled=:is_canceled, home=:home, residence=:residence where id=:id',
+ ['is_canceled' => $sendUnitsEvent->isCanceled, 'home' => $sendUnitsEvent->home, 'residence' => $sendUnitsEvent->residence, 'id' => $sendUnitsEvent->id]
);
}
}