Pārlūkot izejas kodu

Ajout d'un badge pour le nombre de commenraires

François 5 gadi atpakaļ
vecāks
revīzija
21729b91f2

+ 23 - 0
src/AppBundle/Entity/Film.php

@@ -59,6 +59,13 @@ class Film
      */
     private $note;
 
+    /**
+     * @var int
+     *
+     * @ORM\Column(name="nb_coms", type="integer", nullable=true)
+     */
+    private $nbComs;
+
     /**
      * @return \DateTime
      */
@@ -427,6 +434,22 @@ class Film
         $this->note = $note;
     }
 
+    /**
+     * @return int
+     */
+    public function getNbComs()
+    {
+        return $this->nbComs;
+    }
+
+    /**
+     * @param int $nbComs
+     */
+    public function setNbComs($nbComs)
+    {
+        $this->nbComs = $nbComs;
+    }
+
 
 
 }

+ 2 - 0
src/AppBundle/Resources/views/videotheque/liste.html.twig

@@ -60,6 +60,8 @@
 			<td>
 				<a href="{{ path('videotheque_voirfilm', {'id': film.id}) }}">{{ film.titre }}</a>
 				{% if film.new %}<span class="badge badge-light">New</span>{% endif %}
+				{% if film.nbComs %}<span class="badge badge-light" data-toggle="tooltip" data-original-title="{{ film.nbComs }} commentaire(s)">{{ film.nbComs }}</span>{% endif %}
+
 			</td>
 			<td>
 				{% if film.genres is defined %}

+ 1 - 0
src/AppBundle/Service/NoteMoyenne.php

@@ -41,6 +41,7 @@ class NoteMoyenne {
             $note = null;
 
         $film->setNote($note);
+        $film->setNbComs(count($commentaires));
         $this->em->flush();
     }
 }