From abf2790f187322e086947e6832927be5619a04d2 Mon Sep 17 00:00:00 2001 From: filip <25711588+Filip10@users.noreply.github.com> Date: Mon, 2 Dec 2024 20:27:29 +0100 Subject: [PATCH] =?UTF-8?q?pridanie=20,=20=C5=BEe=20zobrazuje=20userovi,?= =?UTF-8?q?=20ke=C4=8F=20on=20dal=20like?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App/Models/Post.php | 12 ++++++++++++ App/Views/Home/ostatne.view.php | 14 +++++++++----- 2 files changed, 21 insertions(+), 5 deletions(-) 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 @@ -