summaryrefslogtreecommitdiff
path: root/src/Model/Event/BaseEvent.php
blob: 0c1795bf89b3dabf65c81f5f263a066414895099 (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
<?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;

  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;
  }
}