diff --git a/App/Models/Post.php b/App/Models/Post.php index 03ff8f5..80b4fbd 100644 --- a/App/Models/Post.php +++ b/App/Models/Post.php @@ -116,4 +116,16 @@ public function likeToggle($userName) $like->save(); } } + + public function isLiker($userName) + { + if (empty($this->id)) { + throw new \Exception("Post must be stored or loaded to check the liker."); + } + + $likes = Like::getAll("post_id = ? AND liker LIKE ?", [$this->id, $userName]); + + return count($likes) > 0; + } + } \ No newline at end of file diff --git a/App/Views/Home/ostatne.view.php b/App/Views/Home/ostatne.view.php index 6128518..a0747ee 100644 --- a/App/Views/Home/ostatne.view.php +++ b/App/Views/Home/ostatne.view.php @@ -21,8 +21,8 @@ -