From 84bdfa04183c7d1051a7d141d4c69e352156236c Mon Sep 17 00:00:00 2001 From: Corentin R Date: Tue, 11 Jun 2024 00:51:50 +0200 Subject: [PATCH] Ugly profile but fonctionnal --- src/Controller/ProfilController.php | 6 ++- templates/posts/post.detail.html.twig | 70 ++++++++++++++++++++++++++ templates/profil/index.html.twig | 11 ++++ var/data.db | Bin 98304 -> 98304 bytes 4 files changed, 85 insertions(+), 2 deletions(-) create mode 100644 templates/posts/post.detail.html.twig diff --git a/src/Controller/ProfilController.php b/src/Controller/ProfilController.php index 2322baa..fbff2b5 100644 --- a/src/Controller/ProfilController.php +++ b/src/Controller/ProfilController.php @@ -20,8 +20,10 @@ class ProfilController extends AbstractController public function profil(int $id): Response { $profil = $this->mgr->find(Profil::class, $id); + $posts = $profil->getPosts(); return $this->render('profil/index.html.twig', [ - 'profil' => $profil + 'profil' => $profil, + 'posts' => $posts ]); } @@ -30,7 +32,7 @@ class ProfilController extends AbstractController { $profil = $this->mgr->find(Profil::class, $id); if ($profil instanceof Profil) { - $this->curentUser->addFollowing($profil); + $profil->addFollower($this->curentUser); return $this->render('profil/index.html.twig', [ ]); } else { diff --git a/templates/posts/post.detail.html.twig b/templates/posts/post.detail.html.twig new file mode 100644 index 0000000..0e86f85 --- /dev/null +++ b/templates/posts/post.detail.html.twig @@ -0,0 +1,70 @@ +{# templates/post/show.html.twig #} + +{% extends 'base.html.twig' %} + +{% block title %}Post - {{ post.title }}{% endblock %} + +{% block stylesheets %} + +{% endblock %} + +{% block body %} +
+

{{ post.profil.name }}

+

{{ post.title }}

+

{{ post.text }}

+
+ Up Votes: {{ post.upVote }} / Down Votes: {{ post.downVote }} +
+
+

Tags:

+
    + {% for tag in post.tags %} +
  • {{ tag.name }}
  • + {% endfor %} +
+
+
+

Commentaires:

+ {% for commentary in post.commentaries %} +
+
{{ commentary.profil.name }}
+
{{ commentary.text }}
+
+ {% endfor %} +
+
+{% endblock %} diff --git a/templates/profil/index.html.twig b/templates/profil/index.html.twig index 834c16f..376aabb 100644 --- a/templates/profil/index.html.twig +++ b/templates/profil/index.html.twig @@ -21,6 +21,17 @@ +
+

Posts

+ {% if posts|length > 0 %} + + {% endif %} +
+