浏览代码

Ajout du prénom

Sangfroid 2 月之前
父节点
当前提交
de712953ab

+ 31 - 0
migrations/Version20250113202807.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 Version20250113202807 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 "user" ADD name VARCHAR(255) DEFAULT NULL');
+    }
+
+    public function down(Schema $schema): void
+    {
+        // this down() migration is auto-generated, please modify it to your needs
+        $this->addSql('ALTER TABLE "user" DROP name');
+    }
+}

+ 2 - 0
src/Command/UserCreateCommand.php

@@ -35,10 +35,12 @@ class UserCreateCommand extends Command
     {
         $io = new SymfonyStyle($input, $output);
         
+        $name = $io->ask("Nom de l'utilisateur");
         $email = $io->ask("Email de l'utilisateur");
         $plainPassword = $io->askHidden("Mot de passe");
 
         $user = new User();
+        $user->setName($name);
         $user->setEmail($email);
         $user->setPassword($this->passwordHasher->hashPassword($user, $plainPassword));
 

+ 20 - 0
src/Entity/User.php

@@ -50,6 +50,9 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface
     #[ORM\OneToMany(targetEntity: UserList::class, mappedBy: 'viewer', orphanRemoval: true)]
     private Collection $userLists;
 
+    #[ORM\Column(length: 255, nullable: true)]
+    private ?string $name = null;
+
     public function __construct()
     {
         $this->commonLists = new ArrayCollection();
@@ -190,4 +193,21 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface
 
         return $this;
     }
+
+    public function getName(): ?string
+    {
+        return $this->name;
+    }
+
+    public function setName(?string $name): static
+    {
+        $this->name = $name;
+
+        return $this;
+    }
+
+    public function getPseudo(): string
+    {
+        return $this->getName() ?? $this->getEmail();
+    }
 }

+ 1 - 1
templates/form/_form.film.html.twig

@@ -3,7 +3,7 @@
 <fieldset class="grid">
 {{ form_rest(form) }}
 <div>
-<input type="submit" id="submit">
+<input type="submit" id="submit" value="Ajouter">
 </div>
 </fieldset>
 

+ 10 - 10
templates/index/index.html.twig

@@ -9,12 +9,12 @@
 <table>
     <thead>
         <tr>
-            <th>Actions</th>
             <th>Nom</th>
             <th>Realisateur</th>
             <th>Genre</th>
             <th>Ajouté par</th>
             <th>Date d'ajout</th>
+            <th></th>
         </tr>
     </thead>
     <tbody>
@@ -27,14 +27,14 @@
         {% set film = entry.film %}
         {% if film not in mesFilms %}
         <tr data-id="{{ film.id }}">
-            <td>
-                <a href="{{ path('app_index', {'id': film.id} ) }}"><i class="fa fa-edit"></i></a>
-            </td>
             <td>{{ film.name }}</td>
             <td>{{ film.realisateur }}</td>
             <td>{{ film.genre }}</td>
-            <td>{{ entry.addedBy.email }}</td>
-            <td>{{ entry.dateAdded | date('d/m/Y') }}
+            <td>{{ entry.addedBy.pseudo }}</td>
+            <td>{{ entry.dateAdded | date('d/m/Y') }}</td>
+            <td>
+                <a href="{{ path('app_index', {'id': film.id} ) }}"><i class="fa fa-edit"></i></a>
+            </td>
         </tr>
         {% endif %}
         {% endfor %}
@@ -48,14 +48,14 @@
         
         {% for film in mesFilms %}
         <tr data-id="{{ film.id }}">
-            <td>
-                <a href="{{ path('app_index', {'id': film.id} ) }}"><i class="fa fa-edit"></i></a>
-            </td>
             <td>{{ film.name }}</td>
             <td>{{ film.realisateur }}</td>
             <td>{{ film.genre }}</td>
-            <td>{{ (film.commonLists | first).addedBy.email }}</td>
+            <td>{{ (film.commonLists | first).addedBy.pseudo }}</td>
             <td>{{ (film.commonLists | first).dateAdded | date('d/m/Y') }}</td>
+            <td>
+                <a href="{{ path('app_index', {'id': film.id} ) }}"><i class="fa fa-edit"></i></a>
+            </td>
         </tr>
         {% endfor %}
     </tbody>