summaryrefslogtreecommitdiff
path: root/src/Model/Event/UpgradeBuilding.php
blob: c014cfe38ad65921a5fab7fe836adfad3dfdebaa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
<?php

namespace App\Model\Event;

use App\DB;
use App\Model\Event;

class UpgradeBuilding extends Event
{
  /**
   * @return void
   */
  public function __invoke(): void
  {
    $payload = json_decode($this->payload, true);

    DB::query(
      'update village_buildings set level=level+1 where id=:id',
      ['id' => $payload['id']]
    );

    DB::query(
      'delete from events where id=:id',
      ['id' => $this->id]
    );
  }
}