diff options
Diffstat (limited to 'src/Controller/Building.php')
-rw-r--r-- | src/Controller/Building.php | 18 |
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( |