summaryrefslogtreecommitdiff
path: root/model/Tag.php
blob: a8324f7bb969891b0a064fba3deec30b6a7de1bd (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
<?php

class Tag extends Model implements Stringable {

    const DB_TABLE = 'tags';

    public int $id;
    public string $tag;
    public int $postsCount;
    public int $visiblePostsCount;

    public function getUrl(): string {
        return '/'.$this->tag.'/';
    }

    public function getPostsCount(bool $is_admin): int {
        return $is_admin ? $this->postsCount : $this->visiblePostsCount;
    }

    public function __toString(): string {
        return $this->tag;
    }

}