src/Entity/User.php line 17

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\UserRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  8. use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
  9. use Symfony\Component\Security\Core\User\UserInterface;
  10. /**
  11.  * @ORM\Entity(repositoryClass=UserRepository::class)
  12.  * @UniqueEntity(fields={"email"}, message="There is already an account with this email")
  13.  */
  14. class User implements UserInterfacePasswordAuthenticatedUserInterface
  15. {
  16.     /**
  17.      * @ORM\Id
  18.      * @ORM\GeneratedValue
  19.      * @ORM\Column(type="integer")
  20.      */
  21.     private $id;
  22.     /**
  23.      * @ORM\Column(type="string", length=180)
  24.      */
  25.     private $email;
  26.     /**
  27.      * @ORM\Column(type="json")
  28.      */
  29.     private $roles = [];
  30.     /**
  31.      * @var string The hashed password
  32.      * @ORM\Column(type="string")
  33.      */
  34.     private $password;
  35.     /**
  36.      * @ORM\Column(type="string", length=255)
  37.      */
  38.     private $nom;
  39.     /**
  40.      * @ORM\Column(type="string", length=255)
  41.      */
  42.     private $prenom;
  43.     /**
  44.      * @ORM\Column(type="string", length=255)
  45.      */
  46.     private $tel;
  47.     /**
  48.      * @ORM\Column(type="datetime_immutable")
  49.      */
  50.     private $createdAt;
  51.     /**
  52.      * @ORM\OneToMany(targetEntity=Reservation::class, mappedBy="user", orphanRemoval=true)
  53.      */
  54.     private $reservations;
  55.     /**
  56.      * @ORM\Column(type="boolean")
  57.      */
  58.     private $isVerified false;
  59.     /**
  60.      * @ORM\Column(type="string", length=255, nullable=true)
  61.      */
  62.     private $atelier;
  63.     /**
  64.      * @ORM\OneToMany(targetEntity=ListeAttente::class, mappedBy="user", orphanRemoval=true)
  65.      */
  66.     private $listeAttentes;
  67.     public function __construct()
  68.     {
  69.         $this->reservations = new ArrayCollection();
  70.         $this->listeAttentes = new ArrayCollection();
  71.     }
  72.     public function getId(): ?int
  73.     {
  74.         return $this->id;
  75.     }
  76.     public function getEmail(): ?string
  77.     {
  78.         return $this->email;
  79.     }
  80.     public function setEmail(string $email): self
  81.     {
  82.         $this->email $email;
  83.         return $this;
  84.     }
  85.     /**
  86.      * A visual identifier that represents this user.
  87.      *
  88.      * @see UserInterface
  89.      */
  90.     public function getUserIdentifier(): string
  91.     {
  92.         return (string) $this->email;
  93.     }
  94.     /**
  95.      * @deprecated since Symfony 5.3, use getUserIdentifier instead
  96.      */
  97.     public function getUsername(): string
  98.     {
  99.         return (string) $this->email;
  100.     }
  101.     /**
  102.      * @see UserInterface
  103.      */
  104.     public function getRoles(): array
  105.     {
  106.         $roles $this->roles;
  107.         // guarantee every user at least has ROLE_USER
  108.         $roles[] = 'ROLE_USER';
  109.         return array_unique($roles);
  110.     }
  111.     public function setRoles(array $roles): self
  112.     {
  113.         $this->roles $roles;
  114.         return $this;
  115.     }
  116.     /**
  117.      * @see PasswordAuthenticatedUserInterface
  118.      */
  119.     public function getPassword(): string
  120.     {
  121.         return $this->password;
  122.     }
  123.     public function setPassword(string $password): self
  124.     {
  125.         $this->password $password;
  126.         return $this;
  127.     }
  128.     /**
  129.      * Returning a salt is only needed, if you are not using a modern
  130.      * hashing algorithm (e.g. bcrypt or sodium) in your security.yaml.
  131.      *
  132.      * @see UserInterface
  133.      */
  134.     public function getSalt(): ?string
  135.     {
  136.         return null;
  137.     }
  138.     /**
  139.      * @see UserInterface
  140.      */
  141.     public function eraseCredentials()
  142.     {
  143.         // If you store any temporary, sensitive data on the user, clear it here
  144.         // $this->plainPassword = null;
  145.     }
  146.     public function getNom(): ?string
  147.     {
  148.         return $this->nom;
  149.     }
  150.     public function setNom(string $nom): self
  151.     {
  152.         $this->nom $nom;
  153.         return $this;
  154.     }
  155.     public function getPrenom(): ?string
  156.     {
  157.         return $this->prenom;
  158.     }
  159.     public function setPrenom(string $prenom): self
  160.     {
  161.         $this->prenom $prenom;
  162.         return $this;
  163.     }
  164.     public function getTel(): ?string
  165.     {
  166.         return $this->tel;
  167.     }
  168.     public function setTel(string $tel): self
  169.     {
  170.         $this->tel $tel;
  171.         return $this;
  172.     }
  173.     public function getCreatedAt(): ?\DateTimeImmutable
  174.     {
  175.         return $this->createdAt;
  176.     }
  177.     public function setCreatedAt(\DateTimeImmutable $createdAt): self
  178.     {
  179.         $this->createdAt $createdAt;
  180.         return $this;
  181.     }
  182.     public function getAtelier(): ?string
  183.     {
  184.         return $this->atelier;
  185.     }
  186.     public function setAtelier(string $atelier): self
  187.     {
  188.         $this->atelier $atelier;
  189.         return $this;
  190.     }
  191.     /**
  192.      * @return Collection<int, Reservation>
  193.      */
  194.     public function getReservations(): Collection
  195.     {
  196.         return $this->reservations;
  197.     }
  198.     public function addReservation(Reservation $reservation): self
  199.     {
  200.         if (!$this->reservations->contains($reservation)) {
  201.             $this->reservations[] = $reservation;
  202.             $reservation->setUser($this);
  203.         }
  204.         return $this;
  205.     }
  206.     public function removeReservation(Reservation $reservation): self
  207.     {
  208.         if ($this->reservations->removeElement($reservation)) {
  209.             // set the owning side to null (unless already changed)
  210.             if ($reservation->getUser() === $this) {
  211.                 $reservation->setUser(null);
  212.             }
  213.         }
  214.         return $this;
  215.     }
  216.     public function isVerified(): bool
  217.     {
  218.         return $this->isVerified;
  219.     }
  220.     public function setIsVerified(bool $isVerified): self
  221.     {
  222.         $this->isVerified $isVerified;
  223.         return $this;
  224.     }
  225.     /**
  226.      * @return Collection<int, ListeAttente>
  227.      */
  228.     public function getListeAttentes(): Collection
  229.     {
  230.         return $this->listeAttentes;
  231.     }
  232.     public function addListeAttente(ListeAttente $listeAttente): self
  233.     {
  234.         if (!$this->listeAttentes->contains($listeAttente)) {
  235.             $this->listeAttentes[] = $listeAttente;
  236.             $listeAttente->setUser($this);
  237.         }
  238.         return $this;
  239.     }
  240.     public function removeListeAttente(ListeAttente $listeAttente): self
  241.     {
  242.         if ($this->listeAttentes->removeElement($listeAttente)) {
  243.             // set the owning side to null (unless already changed)
  244.             if ($listeAttente->getUser() === $this) {
  245.                 $listeAttente->setUser(null);
  246.             }
  247.         }
  248.         return $this;
  249.     }
  250. }