src/Entity/User.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\UserRepository;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  6. use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
  7. use Symfony\Component\Security\Core\User\UserInterface;
  8. #[ORM\Entity(repositoryClassUserRepository::class)]
  9. #[UniqueEntity(fields: ['email'], message'Il y a déjà un compte avec cet e-mail')]
  10. class User implements UserInterfacePasswordAuthenticatedUserInterface
  11. {
  12.     #[ORM\Id]
  13.     #[ORM\GeneratedValue]
  14.     #[ORM\Column]
  15.     private ?int $id null;
  16.     #[ORM\Column(length180uniquetrue)]
  17.     private ?string $email null;
  18.     #[ORM\Column]
  19.     private array $roles = [];
  20.     /**
  21.      * @var string The hashed password
  22.      */
  23.     #[ORM\Column]
  24.     private ?string $password null;
  25.     #[ORM\Column(length255nullabletrue)]
  26.     private ?string $nom null;
  27.     #[ORM\Column(length255nullabletrue)]
  28.     private ?string $prenom null;
  29.     #[ORM\Column(length255nullabletrue)]
  30.     private ?string $tel null;
  31.     public function getId(): ?int
  32.     {
  33.         return $this->id;
  34.     }
  35.     public function getEmail(): ?string
  36.     {
  37.         return $this->email;
  38.     }
  39.     public function setEmail(string $email): static
  40.     {
  41.         $this->email $email;
  42.         return $this;
  43.     }
  44.     /**
  45.      * A visual identifier that represents this user.
  46.      *
  47.      * @see UserInterface
  48.      */
  49.     public function getUserIdentifier(): string
  50.     {
  51.         return (string) $this->email;
  52.     }
  53.     /**
  54.      * @see UserInterface
  55.      */
  56.     public function getRoles(): array
  57.     {
  58.         $roles $this->roles;
  59.         // guarantee every user at least has ROLE_USER
  60.         $roles[] = 'ROLE_USER';
  61.         return array_unique($roles);
  62.     }
  63.     public function setRoles(array $roles): static
  64.     {
  65.         $this->roles $roles;
  66.         return $this;
  67.     }
  68.     /**
  69.      * @see PasswordAuthenticatedUserInterface
  70.      */
  71.     public function getPassword(): string
  72.     {
  73.         return $this->password;
  74.     }
  75.     public function setPassword(string $password): static
  76.     {
  77.         $this->password $password;
  78.         return $this;
  79.     }
  80.     /**
  81.      * @see UserInterface
  82.      */
  83.     public function eraseCredentials(): void
  84.     {
  85.         // If you store any temporary, sensitive data on the user, clear it here
  86.         // $this->plainPassword = null;
  87.     }
  88.     public function getNom(): ?string
  89.     {
  90.         return $this->nom;
  91.     }
  92.     public function setNom(?string $nom): static
  93.     {
  94.         $this->nom $nom;
  95.         return $this;
  96.     }
  97.     public function getPrenom(): ?string
  98.     {
  99.         return $this->prenom;
  100.     }
  101.     public function setPrenom(?string $prenom): static
  102.     {
  103.         $this->prenom $prenom;
  104.         return $this;
  105.     }
  106.     public function getTel(): ?string
  107.     {
  108.         return $this->tel;
  109.     }
  110.     public function setTel(?string $tel): static
  111.     {
  112.         $this->tel $tel;
  113.         return $this;
  114.     }
  115. }