summaryrefslogtreecommitdiff
path: root/src/Model/Event/BaseEvent.php
blob: 2e2564bc2f7d9f06b49d6ae4844aaee5d783a170 (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
28
29
30
<?php

namespace App\Model\Event;

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

abstract class BaseEvent
{
  public int $id;
  public int $eventId;

  public \DateTime $createdAt;
  public \DateTime $updatedAt;

  public Event $event;

  abstract function dbInsert(): void;
  abstract function dbDelete(): void;
  abstract function cancel(): void;

  public function getEvent(): Event
  {
    if (! isset($this->event)) {
      $this->event = DB::fetch(Event::class, 'select * from events where id=:id', ['id' => $this->eventId])[0];
    }

    return $this->event;
  }
}