aboutsummaryrefslogtreecommitdiff
path: root/model/Tag.php
diff options
context:
space:
mode:
authorEvgeny Zinoviev <me@ch1p.io>2022-07-09 19:40:17 +0300
committerEvgeny Zinoviev <me@ch1p.io>2022-07-09 19:40:17 +0300
commitf7bfdf58def6aadc922e1632f407d1418269a0d7 (patch)
treed7a0b2819e6a26c11d40ee0b27267ea827fbb345 /model/Tag.php
initial
Diffstat (limited to 'model/Tag.php')
-rw-r--r--model/Tag.php24
1 files changed, 24 insertions, 0 deletions
diff --git a/model/Tag.php b/model/Tag.php
new file mode 100644
index 0000000..a8324f7
--- /dev/null
+++ b/model/Tag.php
@@ -0,0 +1,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;
+ }
+
+}