src/Entity/User.php line 18

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.  * @ORM\Table(name="`user`")
  13.  * @UniqueEntity(fields={"email"}, message="There is already an account with this email")
  14.  */
  15. class User implements UserInterfacePasswordAuthenticatedUserInterface
  16. {
  17.     /**
  18.      * @ORM\Id
  19.      * @ORM\GeneratedValue
  20.      * @ORM\Column(type="integer")
  21.      */
  22.     private $id;
  23.     /**
  24.      * @ORM\Column(type="string", length=180, unique=true)
  25.      */
  26.     private $email;
  27.     /**
  28.      * @ORM\Column(type="json")
  29.      */
  30.     private $roles = [];
  31.     /**
  32.      * @var string The hashed password
  33.      * @ORM\Column(type="string")
  34.      */
  35.     private $password;
  36.     /**
  37.      * @ORM\Column(type="boolean")
  38.      */
  39.     private $isVerified false;
  40.     /**
  41.      * @ORM\OneToOne(targetEntity=Installateur::class, mappedBy="user", cascade={"persist", "remove"})
  42.      */
  43.     private $installateur;
  44.     /**
  45.      * @ORM\OneToOne(targetEntity=Obliges::class, mappedBy="user", cascade={"persist", "remove"})
  46.      */
  47.     private $obliges;
  48.     /**
  49.      * @ORM\OneToOne(targetEntity=Equipe::class, mappedBy="user", cascade={"persist", "remove"})
  50.      */
  51.     private $equipe;
  52.     /**
  53.      * @ORM\OneToMany(targetEntity=Notifications::class, mappedBy="user_id")
  54.      */
  55.     private $notifications;
  56.     /**
  57.      * @ORM\OneToMany(targetEntity=Notifications::class, mappedBy="sender")
  58.      */
  59.     private $sendernotif;
  60.     /**
  61.      * @ORM\OneToMany(targetEntity=Tokenpassword::class, mappedBy="user")
  62.      */
  63.     private $tokenpasswords;
  64.     /**
  65.      * @ORM\OneToMany(targetEntity=HistoriqueDeal::class, mappedBy="user")
  66.      */
  67.     private $historiqueDeals;
  68.     /**
  69.      * @ORM\OneToMany(targetEntity=CommentaireDeal::class, mappedBy="user")
  70.      */
  71.     private $commentaireDeals;
  72.     /**
  73.      * @ORM\OneToMany(targetEntity=CommentaireInstalleur::class, mappedBy="user")
  74.      */
  75.     private $commentaireInstalleurs;
  76.     /**
  77.      * @ORM\OneToMany(targetEntity=Filtre::class, mappedBy="user")
  78.      */
  79.     private $filtres;
  80.     /**
  81.      * @ORM\OneToMany(targetEntity=CommentaireContrat::class, mappedBy="user")
  82.      */
  83.     private $commentaireContrats;
  84.     /**
  85.      * @ORM\OneToMany(targetEntity=CommentaireFactureaaf::class, mappedBy="user")
  86.      */
  87.     private $commentaireFactureaafs;
  88.     /**
  89.      * @ORM\OneToMany(targetEntity=CommentaireAppelqualite::class, mappedBy="user")
  90.      */
  91.     private $commentaireAppelqualites;
  92.  
  93.     public function __construct()
  94.     {
  95.         $this->notifications = new ArrayCollection();
  96.         $this->sendernotif = new ArrayCollection();
  97.         $this->tokenpasswords = new ArrayCollection();
  98.         $this->historiqueDeals = new ArrayCollection();
  99.         $this->commentaireDeals = new ArrayCollection();
  100.         $this->commentaireInstalleurs = new ArrayCollection();
  101.         $this->filtres = new ArrayCollection();
  102.         $this->commentaireContrats = new ArrayCollection();
  103.         $this->commentaireFactureaafs = new ArrayCollection();
  104.         $this->commentaireAppelqualites = new ArrayCollection();
  105.     }
  106.     public function getId(): ?int
  107.     {
  108.         return $this->id;
  109.     }
  110.     public function getEmail(): ?string
  111.     {
  112.         return $this->email;
  113.     }
  114.     public function setEmail(string $email): self
  115.     {
  116.         $this->email $email;
  117.         return $this;
  118.     }
  119.     /**
  120.      * A visual identifier that represents this user.
  121.      *
  122.      * @see UserInterface
  123.      */
  124.     public function getUserIdentifier(): string
  125.     {
  126.         return (string) $this->email;
  127.     }
  128.     /**
  129.      * @deprecated since Symfony 5.3, use getUserIdentifier instead
  130.      */
  131.     public function getUsername(): string
  132.     {
  133.         return (string) $this->email;
  134.     }
  135.     /**
  136.      * @see UserInterface
  137.      */
  138.     public function getRoles(): array
  139.     {
  140.         $roles $this->roles;
  141.         // guarantee every user at least has ROLE_USER
  142.         $roles[] = 'ROLE_USER';
  143.         return array_unique($roles);
  144.     }
  145.     public function setRoles(array $roles): self
  146.     {
  147.         $this->roles $roles;
  148.         return $this;
  149.     }
  150.     /**
  151.      * @see PasswordAuthenticatedUserInterface
  152.      */
  153.     public function getPassword(): string
  154.     {
  155.         return $this->password;
  156.     }
  157.     public function setPassword(string $password): self
  158.     {
  159.         $this->password $password;
  160.         return $this;
  161.     }
  162.     /**
  163.      * Returning a salt is only needed, if you are not using a modern
  164.      * hashing algorithm (e.g. bcrypt or sodium) in your security.yaml.
  165.      *
  166.      * @see UserInterface
  167.      */
  168.     public function getSalt(): ?string
  169.     {
  170.         return null;
  171.     }
  172.     /**
  173.      * @see UserInterface
  174.      */
  175.     public function eraseCredentials()
  176.     {
  177.         // If you store any temporary, sensitive data on the user, clear it here
  178.         // $this->plainPassword = null;
  179.     }
  180.     public function isVerified(): bool
  181.     {
  182.         return $this->isVerified;
  183.     }
  184.     public function setIsVerified(bool $isVerified): self
  185.     {
  186.         $this->isVerified $isVerified;
  187.         return $this;
  188.     }
  189.   
  190.     public function getInstallateur(): ?Installateur
  191.     {
  192.         return $this->installateur;
  193.     }
  194.     public function setInstallateur(?Installateur $installateur): self
  195.     {
  196.         // unset the owning side of the relation if necessary
  197.         if ($installateur === null && $this->installateur !== null) {
  198.             $this->installateur->setUser(null);
  199.         }
  200.         // set the owning side of the relation if necessary
  201.         if ($installateur !== null && $installateur->getUser() !== $this) {
  202.             $installateur->setUser($this);
  203.         }
  204.         $this->installateur $installateur;
  205.         return $this;
  206.     }
  207.     public function getObliges(): ?Obliges
  208.     {
  209.         return $this->obliges;
  210.     }
  211.     public function setObliges(?Obliges $obliges): self
  212.     {
  213.         // unset the owning side of the relation if necessary
  214.         if ($obliges === null && $this->obliges !== null) {
  215.             $this->obliges->setUser(null);
  216.         }
  217.         // set the owning side of the relation if necessary
  218.         if ($obliges !== null && $obliges->getUser() !== $this) {
  219.             $obliges->setUser($this);
  220.         }
  221.         $this->obliges $obliges;
  222.         return $this;
  223.     }
  224.     public function getEquipe(): ?Equipe
  225.     {
  226.         return $this->equipe;
  227.     }
  228.     public function setEquipe(?Equipe $equipe): self
  229.     {
  230.         // unset the owning side of the relation if necessary
  231.         if ($equipe === null && $this->equipe !== null) {
  232.             $this->equipe->setUser(null);
  233.         }
  234.         // set the owning side of the relation if necessary
  235.         if ($equipe !== null && $equipe->getUser() !== $this) {
  236.             $equipe->setUser($this);
  237.         }
  238.         $this->equipe $equipe;
  239.         return $this;
  240.     }
  241.     /**
  242.      * @return Collection<int, Notifications>
  243.      */
  244.     public function getNotifications(): Collection
  245.     {
  246.         return $this->notifications;
  247.     }
  248.     public function addNotification(Notifications $notification): self
  249.     {
  250.         if (!$this->notifications->contains($notification)) {
  251.             $this->notifications[] = $notification;
  252.             $notification->setUserId($this);
  253.         }
  254.         return $this;
  255.     }
  256.     public function removeNotification(Notifications $notification): self
  257.     {
  258.         if ($this->notifications->removeElement($notification)) {
  259.             // set the owning side to null (unless already changed)
  260.             if ($notification->getUserId() === $this) {
  261.                 $notification->setUserId(null);
  262.             }
  263.         }
  264.         return $this;
  265.     }
  266.     /**
  267.      * @return Collection<int, Notifications>
  268.      */
  269.     public function getSendernotif(): Collection
  270.     {
  271.         return $this->sendernotif;
  272.     }
  273.     public function addSendernotif(Notifications $sendernotif): self
  274.     {
  275.         if (!$this->sendernotif->contains($sendernotif)) {
  276.             $this->sendernotif[] = $sendernotif;
  277.             $sendernotif->setSender($this);
  278.         }
  279.         return $this;
  280.     }
  281.     public function removeSendernotif(Notifications $sendernotif): self
  282.     {
  283.         if ($this->sendernotif->removeElement($sendernotif)) {
  284.             // set the owning side to null (unless already changed)
  285.             if ($sendernotif->getSender() === $this) {
  286.                 $sendernotif->setSender(null);
  287.             }
  288.         }
  289.         return $this;
  290.     }
  291.     /**
  292.      * @return Collection<int, Tokenpassword>
  293.      */
  294.     public function getTokenpasswords(): Collection
  295.     {
  296.         return $this->tokenpasswords;
  297.     }
  298.     public function addTokenpassword(Tokenpassword $tokenpassword): self
  299.     {
  300.         if (!$this->tokenpasswords->contains($tokenpassword)) {
  301.             $this->tokenpasswords[] = $tokenpassword;
  302.             $tokenpassword->setUser($this);
  303.         }
  304.         return $this;
  305.     }
  306.     public function removeTokenpassword(Tokenpassword $tokenpassword): self
  307.     {
  308.         if ($this->tokenpasswords->removeElement($tokenpassword)) {
  309.             // set the owning side to null (unless already changed)
  310.             if ($tokenpassword->getUser() === $this) {
  311.                 $tokenpassword->setUser(null);
  312.             }
  313.         }
  314.         return $this;
  315.     }
  316.     /**
  317.      * @return Collection<int, HistoriqueDeal>
  318.      */
  319.     public function getHistoriqueDeals(): Collection
  320.     {
  321.         return $this->historiqueDeals;
  322.     }
  323.     public function addHistoriqueDeal(HistoriqueDeal $historiqueDeal): self
  324.     {
  325.         if (!$this->historiqueDeals->contains($historiqueDeal)) {
  326.             $this->historiqueDeals[] = $historiqueDeal;
  327.             $historiqueDeal->setUser($this);
  328.         }
  329.         return $this;
  330.     }
  331.     public function removeHistoriqueDeal(HistoriqueDeal $historiqueDeal): self
  332.     {
  333.         if ($this->historiqueDeals->removeElement($historiqueDeal)) {
  334.             // set the owning side to null (unless already changed)
  335.             if ($historiqueDeal->getUser() === $this) {
  336.                 $historiqueDeal->setUser(null);
  337.             }
  338.         }
  339.         return $this;
  340.     }
  341.     /**
  342.      * @return Collection<int, CommentaireDeal>
  343.      */
  344.     public function getCommentaireDeals(): Collection
  345.     {
  346.         return $this->commentaireDeals;
  347.     }
  348.     public function addCommentaireDeal(CommentaireDeal $commentaireDeal): self
  349.     {
  350.         if (!$this->commentaireDeals->contains($commentaireDeal)) {
  351.             $this->commentaireDeals[] = $commentaireDeal;
  352.             $commentaireDeal->setUser($this);
  353.         }
  354.         return $this;
  355.     }
  356.     public function removeCommentaireDeal(CommentaireDeal $commentaireDeal): self
  357.     {
  358.         if ($this->commentaireDeals->removeElement($commentaireDeal)) {
  359.             // set the owning side to null (unless already changed)
  360.             if ($commentaireDeal->getUser() === $this) {
  361.                 $commentaireDeal->setUser(null);
  362.             }
  363.         }
  364.         return $this;
  365.     }
  366.     /**
  367.      * @return Collection<int, CommentaireInstalleur>
  368.      */
  369.     public function getCommentaireInstalleurs(): Collection
  370.     {
  371.         return $this->commentaireInstalleurs;
  372.     }
  373.     public function addCommentaireInstalleur(CommentaireInstalleur $commentaireInstalleur): self
  374.     {
  375.         if (!$this->commentaireInstalleurs->contains($commentaireInstalleur)) {
  376.             $this->commentaireInstalleurs[] = $commentaireInstalleur;
  377.             $commentaireInstalleur->setUser($this);
  378.         }
  379.         return $this;
  380.     }
  381.     public function removeCommentaireInstalleur(CommentaireInstalleur $commentaireInstalleur): self
  382.     {
  383.         if ($this->commentaireInstalleurs->removeElement($commentaireInstalleur)) {
  384.             // set the owning side to null (unless already changed)
  385.             if ($commentaireInstalleur->getUser() === $this) {
  386.                 $commentaireInstalleur->setUser(null);
  387.             }
  388.         }
  389.         return $this;
  390.     }
  391.     /**
  392.      * @return Collection<int, Filtre>
  393.      */
  394.     public function getFiltres(): Collection
  395.     {
  396.         return $this->filtres;
  397.     }
  398.     public function addFiltre(Filtre $filtre): self
  399.     {
  400.         if (!$this->filtres->contains($filtre)) {
  401.             $this->filtres[] = $filtre;
  402.             $filtre->setUser($this);
  403.         }
  404.         return $this;
  405.     }
  406.     public function removeFiltre(Filtre $filtre): self
  407.     {
  408.         if ($this->filtres->removeElement($filtre)) {
  409.             // set the owning side to null (unless already changed)
  410.             if ($filtre->getUser() === $this) {
  411.                 $filtre->setUser(null);
  412.             }
  413.         }
  414.         return $this;
  415.     }
  416.     /**
  417.      * @return Collection<int, CommentaireContrat>
  418.      */
  419.     public function getCommentaireContrats(): Collection
  420.     {
  421.         return $this->commentaireContrats;
  422.     }
  423.     public function addCommentaireContrat(CommentaireContrat $commentaireContrat): self
  424.     {
  425.         if (!$this->commentaireContrats->contains($commentaireContrat)) {
  426.             $this->commentaireContrats[] = $commentaireContrat;
  427.             $commentaireContrat->setUser($this);
  428.         }
  429.         return $this;
  430.     }
  431.     public function removeCommentaireContrat(CommentaireContrat $commentaireContrat): self
  432.     {
  433.         if ($this->commentaireContrats->removeElement($commentaireContrat)) {
  434.             // set the owning side to null (unless already changed)
  435.             if ($commentaireContrat->getUser() === $this) {
  436.                 $commentaireContrat->setUser(null);
  437.             }
  438.         }
  439.         return $this;
  440.     }
  441.     /**
  442.      * @return Collection<int, CommentaireFactureaaf>
  443.      */
  444.     public function getCommentaireFactureaafs(): Collection
  445.     {
  446.         return $this->commentaireFactureaafs;
  447.     }
  448.     public function addCommentaireFactureaaf(CommentaireFactureaaf $commentaireFactureaaf): self
  449.     {
  450.         if (!$this->commentaireFactureaafs->contains($commentaireFactureaaf)) {
  451.             $this->commentaireFactureaafs[] = $commentaireFactureaaf;
  452.             $commentaireFactureaaf->setUser($this);
  453.         }
  454.         return $this;
  455.     }
  456.     public function removeCommentaireFactureaaf(CommentaireFactureaaf $commentaireFactureaaf): self
  457.     {
  458.         if ($this->commentaireFactureaafs->removeElement($commentaireFactureaaf)) {
  459.             // set the owning side to null (unless already changed)
  460.             if ($commentaireFactureaaf->getUser() === $this) {
  461.                 $commentaireFactureaaf->setUser(null);
  462.             }
  463.         }
  464.         return $this;
  465.     }
  466.     /**
  467.      * @return Collection<int, CommentaireAppelqualite>
  468.      */
  469.     public function getCommentaireAppelqualites(): Collection
  470.     {
  471.         return $this->commentaireAppelqualites;
  472.     }
  473.     public function addCommentaireAppelqualite(CommentaireAppelqualite $commentaireAppelqualite): self
  474.     {
  475.         if (!$this->commentaireAppelqualites->contains($commentaireAppelqualite)) {
  476.             $this->commentaireAppelqualites[] = $commentaireAppelqualite;
  477.             $commentaireAppelqualite->setUser($this);
  478.         }
  479.         return $this;
  480.     }
  481.     public function removeCommentaireAppelqualite(CommentaireAppelqualite $commentaireAppelqualite): self
  482.     {
  483.         if ($this->commentaireAppelqualites->removeElement($commentaireAppelqualite)) {
  484.             // set the owning side to null (unless already changed)
  485.             if ($commentaireAppelqualite->getUser() === $this) {
  486.                 $commentaireAppelqualite->setUser(null);
  487.             }
  488.         }
  489.         return $this;
  490.     }
  491.     
  492. }