summaryrefslogtreecommitdiff
path: root/src/Controller/Building.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/Building.php
parent3afcaef927391db23fe23c6c8c26b8960e8dae32 (diff)
event tables
Diffstat (limited to 'src/Controller/Building.php')
-rw-r--r--src/Controller/Building.php18
1 files changed, 6 insertions, 12 deletions
diff --git a/src/Controller/Building.php b/src/Controller/Building.php
index 6199286..876f474 100644
--- a/src/Controller/Building.php
+++ b/src/Controller/Building.php
@@ -2,7 +2,6 @@
namespace App\Controller;
-use App\DB;
use App\Model\Building as Model;
use App\Model\Event;
use App\Model\Event\UpgradeBuilding;
@@ -28,18 +27,13 @@ class Building
$village->updateResources();
// event
- $event = new UpgradeBuilding();
- $event->type = 'UpgradeBuilding';
+ $event = new Event();
$event->time = (new \DateTime())->add(\DateInterval::createFromDateString($building->getBuildTime() . ' seconds'));
- $event->payload = json_encode([
- 'type' => $building->type,
- 'village_id' => $building->villageId,
- ]);
-
- DB::query(
- 'insert into events (type, time, payload, village_id) VALUES (:type, :time, :payload, :id)',
- ['type' => $event->type, 'time' => $event->time->format('c'), 'payload' => $event->payload, 'id' => $village->id]
- );
+ $event->villageId = $building->villageId;
+ $upgradeBuildingEvent = new UpgradeBuilding();
+ $upgradeBuildingEvent->event = $event;
+ $upgradeBuildingEvent->type = $building->type;
+ $upgradeBuildingEvent->dbInsert();
return new RedirectResponse(
Router::generate(