event = $event; $this->type = $type; } /** * @return void */ public function __invoke(): void { DB::query( << $this->type, 'village_id' => $this->event->villageId] ); } public function sqlInsert(): void { DB::query( '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] ); } }