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, unique=true)
  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, nullable=true)
  37.      */
  38.     private $Nom;
  39.     /**
  40.      * @ORM\Column(type="string", length=255, nullable=true)
  41.      */
  42.     private $Prenom;
  43.     /**
  44.      * @ORM\Column(type="string", length=255, nullable=true)
  45.      */
  46.     private $Telephone;
  47.     /**
  48.      * @ORM\OneToMany(targetEntity=Reservations::class, mappedBy="User")
  49.      */
  50.     private $reservations;
  51.     /**
  52.      * @ORM\Column(type="boolean", nullable=true)
  53.      */
  54.     private $IgnorePaiement;
  55.     /**
  56.      * @ORM\Column(type="integer", nullable=true)
  57.      */
  58.     private $Archive;
  59.     /**
  60.      * @ORM\Column(type="string", length=255, nullable=true)
  61.      */
  62.     private $Token;
  63.     public function __construct()
  64.     {
  65.         $this->reservations = new ArrayCollection();
  66.     }
  67.     public function getId(): ?int
  68.     {
  69.         return $this->id;
  70.     }
  71.     public function getEmail(): ?string
  72.     {
  73.         return $this->email;
  74.     }
  75.     public function setEmail(string $email): self
  76.     {
  77.         $this->email $email;
  78.         return $this;
  79.     }
  80.     /**
  81.      * A visual identifier that represents this user.
  82.      *
  83.      * @see UserInterface
  84.      */
  85.     public function getUserIdentifier(): string
  86.     {
  87.         return (string) $this->email;
  88.     }
  89.     /**
  90.      * @deprecated since Symfony 5.3, use getUserIdentifier instead
  91.      */
  92.     public function getUsername(): string
  93.     {
  94.         return (string) $this->email;
  95.     }
  96.     /**
  97.      * @see UserInterface
  98.      */
  99.     public function getRoles(): array
  100.     {
  101.         $roles $this->roles;
  102.         // guarantee every user at least has ROLE_USER
  103.         $roles[] = 'ROLE_USER';
  104.         return array_unique($roles);
  105.     }
  106.     public function setRoles(array $roles): self
  107.     {
  108.         $this->roles $roles;
  109.         return $this;
  110.     }
  111.     /**
  112.      * @see PasswordAuthenticatedUserInterface
  113.      */
  114.     public function getPassword(): string
  115.     {
  116.         return $this->password;
  117.     }
  118.     public function setPassword(string $password): self
  119.     {
  120.         $this->password $password;
  121.         return $this;
  122.     }
  123.     /**
  124.      * Returning a salt is only needed, if you are not using a modern
  125.      * hashing algorithm (e.g. bcrypt or sodium) in your security.yaml.
  126.      *
  127.      * @see UserInterface
  128.      */
  129.     public function getSalt(): ?string
  130.     {
  131.         return null;
  132.     }
  133.     /**
  134.      * @see UserInterface
  135.      */
  136.     public function eraseCredentials()
  137.     {
  138.         // If you store any temporary, sensitive data on the user, clear it here
  139.         // $this->plainPassword = null;
  140.     }
  141.     public function getNom(): ?string
  142.     {
  143.         return $this->Nom;
  144.     }
  145.     public function setNom(?string $Nom): self
  146.     {
  147.         $this->Nom $Nom;
  148.         return $this;
  149.     }
  150.     public function getPrenom(): ?string
  151.     {
  152.         return $this->Prenom;
  153.     }
  154.     public function setPrenom(?string $Prenom): self
  155.     {
  156.         $this->Prenom $Prenom;
  157.         return $this;
  158.     }
  159.     public function getTelephone(): ?string
  160.     {
  161.         return $this->Telephone;
  162.     }
  163.     public function setTelephone(?string $Telephone): self
  164.     {
  165.         $this->Telephone $Telephone;
  166.         return $this;
  167.     }
  168.     /**
  169.      * @return Collection<int, Reservations>
  170.      */
  171.     public function getReservations(): Collection
  172.     {
  173.         return $this->reservations;
  174.     }
  175.     public function addReservation(Reservations $reservation): self
  176.     {
  177.         if (!$this->reservations->contains($reservation)) {
  178.             $this->reservations[] = $reservation;
  179.             $reservation->setUser($this);
  180.         }
  181.         return $this;
  182.     }
  183.     public function removeReservation(Reservations $reservation): self
  184.     {
  185.         if ($this->reservations->removeElement($reservation)) {
  186.             // set the owning side to null (unless already changed)
  187.             if ($reservation->getUser() === $this) {
  188.                 $reservation->setUser(null);
  189.             }
  190.         }
  191.         return $this;
  192.     }
  193.     public function isIgnorePaiement(): ?bool
  194.     {
  195.         return $this->IgnorePaiement;
  196.     }
  197.     public function setIgnorePaiement(?bool $IgnorePaiement): self
  198.     {
  199.         $this->IgnorePaiement $IgnorePaiement;
  200.         return $this;
  201.     }
  202.     public function getArchive(): ?int
  203.     {
  204.         return $this->Archive;
  205.     }
  206.     public function setArchive(?int $Archive): self
  207.     {
  208.         $this->Archive $Archive;
  209.         return $this;
  210.     }
  211.     public function getToken(): ?string
  212.     {
  213.         return $this->Token;
  214.     }
  215.     public function setToken(?string $Token): self
  216.     {
  217.         $this->Token $Token;
  218.         return $this;
  219.     }
  220. }