Kaynağa Gözat

Ajout de la date de sortie

François Drouhard 3 yıl önce
ebeveyn
işleme
e21d19e06c

+ 31 - 0
migrations/Version20211117180948.php

@@ -0,0 +1,31 @@
+<?php
+
+declare(strict_types=1);
+
+namespace DoctrineMigrations;
+
+use Doctrine\DBAL\Schema\Schema;
+use Doctrine\Migrations\AbstractMigration;
+
+/**
+ * Auto-generated Migration: Please modify to your needs!
+ */
+final class Version20211117180948 extends AbstractMigration
+{
+    public function getDescription(): string
+    {
+        return '';
+    }
+
+    public function up(Schema $schema): void
+    {
+        // this up() migration is auto-generated, please modify it to your needs
+        $this->addSql('ALTER TABLE film ADD date_sortie DATE DEFAULT NULL');
+    }
+
+    public function down(Schema $schema): void
+    {
+        // this down() migration is auto-generated, please modify it to your needs
+        $this->addSql('ALTER TABLE film DROP date_sortie');
+    }
+}

+ 17 - 0
src/Entity/Film.php

@@ -157,6 +157,11 @@ class Film
      */
     private $information;
 
+    /**
+     * @ORM\Column(type="date", nullable=true)
+     */
+    private $dateSortie;
+
     /**
      * @return \App\Entity\User $authered
      */
@@ -512,6 +517,18 @@ class Film
         return $this;
     }
 
+    public function getDateSortie(): ?\DateTimeInterface
+    {
+        return $this->dateSortie;
+    }
+
+    public function setDateSortie(?\DateTimeInterface $dateSortie): self
+    {
+        $this->dateSortie = $dateSortie;
+
+        return $this;
+    }
+
 
 
 }

+ 5 - 0
src/Form/FilmType.php

@@ -34,6 +34,11 @@ class FilmType extends AbstractType
             ->add('mediaVideo', MediaVideoType::class,array(
                 'required'  =>  false,
             ))
+            ->add('dateSortie', DateType::class, [
+                'html5'     =>  true,
+                'widget'    =>  'single_text',
+                'required'  =>  false
+            ])
             ->add('information', TextareaType::class, array(
                 'required' => false,
             ))

+ 1 - 0
templates/videotheque/form.html.twig

@@ -8,6 +8,7 @@
                     {{ form_row(form.titre) }}
                     {{ form_row(form.annee) }}
                     {{ form_row(form.lien) }}
+                    {{ form_row(form.dateSortie) }}
                     {% form_theme form 'bootstrap_5_layout.html.twig' %}
                     {{ form_row(form.information) }}
 

+ 2 - 0
templates/videotheque/liste_tableaux.html.twig

@@ -43,6 +43,7 @@
 					<th>Réalisateur</th>
 					<th style="width:5em;">Note</th>
 					<th style="width:5em;">Année</th>
+					<th style="width:6em;">Sortie</th>
 				</tr>
 			</thead>
 			<tbody id="tableFilms">
@@ -128,6 +129,7 @@
 						{% endif %}
 					</td>
 					<td>{{ film.annee | date('Y') }}</td>
+					<td>{% if film.dateSortie %}{{ film.dateSortie | date('d/m/y')}}{% endif %}</td>
 				</tr>
 				{% endfor %}
 			</tbody>

+ 6 - 0
templates/videotheque/liste_vignettes.html.twig

@@ -113,6 +113,12 @@
 							<th>Informations</th>
 							<td>{% if film.information %}{{ film.information | nl2br }}{% else %}Pas d'information{% endif %}</td>
 						</tr>
+						{% if film.dateSortie %}
+							<tr>
+								<th>Date de sortie</th>
+								<td>{{ film.dateSortie | date('d/m/y')}}</td>
+							</tr>
+						{% endif %}
 					</tbody>
 				</table>
 			</div>

+ 6 - 0
templates/videotheque/voirfilm.html.twig

@@ -85,6 +85,12 @@
                         <dt class="col-4">Lien</dt>
                         <dd class="col-8"><a href="{{ film.lien }}"><i class="fa fa-external-link"></i></a></dd>
                         {% endif %}
+                        {% if film.dateSortie %}
+                            <dt class="col-4">Sortie</dt>
+                            <dd class="col-8">
+                                {{ film.dateSortie | date('d/m/y')}}
+                            </dd>
+                        {% endif %}
                     </dl>
                 </div>
                 <div class="card-footer">