diff options
author | Daniel Weipert <code@drogueronin.de> | 2023-11-29 11:03:15 +0100 |
---|---|---|
committer | Daniel Weipert <code@drogueronin.de> | 2023-11-29 11:03:15 +0100 |
commit | fa9096c0ab521aae45cab6c48a54290d14a221b9 (patch) | |
tree | 61466b792c2714848cfea00594456ac06c259c94 /src/Model/Event/UpgradeBuilding.php | |
parent | 3afcaef927391db23fe23c6c8c26b8960e8dae32 (diff) |
event tables
Diffstat (limited to 'src/Model/Event/UpgradeBuilding.php')
-rw-r--r-- | src/Model/Event/UpgradeBuilding.php | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/src/Model/Event/UpgradeBuilding.php b/src/Model/Event/UpgradeBuilding.php index f4f427d..a426a21 100644 --- a/src/Model/Event/UpgradeBuilding.php +++ b/src/Model/Event/UpgradeBuilding.php @@ -7,20 +7,15 @@ use App\Model\Event; class UpgradeBuilding extends BaseEvent { - public Event $event; public string $type; - public function __construct(Event $event, string $type) - { - $this->event = $event; - $this->type = $type; - } - /** * @return void */ public function __invoke(): void { + $this->getEvent(); + DB::query( <<<SQL insert into village_buildings (level, type, village_id) @@ -32,16 +27,22 @@ class UpgradeBuilding extends BaseEvent ); } - public function sqlInsert(): void + public function dbInsert(): void { DB::query( - 'insert into events (time, village_id) values (:time, :village_id)', + 'insert into events (time, village_id) VALUES (:time, :village_id)', ['time' => $this->event->time->format('c'), 'village_id' => $this->event->villageId] ); DB::query( - 'insert into events_upgrade_building (event_id, type) values (:event_id, :type)', - ['event_id' => DB::$connection->lastInsertId(), $this->type] + 'insert into events_upgrade_building (event_id, type) VALUES (:event_id, :type)', + ['event_id' => DB::$connection->lastInsertId(), 'type' => $this->type] ); } + + public function dbDelete(): void + { + DB::query('delete from events where id=:id', ['id' => $this->eventId]); + DB::query('delete from events_upgrade_building where id=:id', ['id' => $this->id]); + } } |