src/Entity/User.php line 24

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\UserRepository;
  4. use App\Validator\PhoneNumberConstraint;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Scheb\TwoFactorBundle\Model\Email\TwoFactorInterface;
  9. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  10. use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
  11. use Symfony\Component\Security\Core\User\UserInterface;
  12. use Symfony\Component\Serializer\Annotation\Groups;
  13. /**
  14.  * Utilisateur et administrateurs.
  15.  *
  16.  * @UniqueEntity(fields={"username"}, message="Ce compte existe déjà")
  17.  */
  18. #[ORM\Table]
  19. #[ORM\Index(name'username'columns: ['username'])]
  20. #[ORM\Entity(repositoryClassUserRepository::class)]
  21. class User implements UserInterface\SerializablePasswordAuthenticatedUserInterfaceTwoFactorInterface
  22. {
  23.     // ------------- Maintainers -----------------------
  24.     /** User prospect status */
  25.     public const PROSPECT 1;
  26.     /** User authorized status */
  27.     public const AUTHORIZED 2;
  28.     /** User inactive status */
  29.     public const EXPIRED 3;
  30.     // ------------- Clients -----------------------
  31.     /** Client prospect status */
  32.     public const CLIENT_PROSPECT 4;
  33.     /** Client suspended status */
  34.     public const SUSPENDED 5;
  35.     /** Client closed status */
  36.     public const CLOSED 6;
  37.     /** Client status */
  38.     public const CLIENT 7;
  39.     /** Client expired status */
  40.     public const CLIENT_EXPIRED 8;
  41.     protected static $statusLabels = [
  42.         => 'Prospect',
  43.         => 'Authorized',
  44.         => 'Expired',
  45.     ];
  46.     protected static $clientStatusLabels = [
  47.         => 'ProspectClient',
  48.         => 'Suspended',
  49.         => 'Closed',
  50.         => 'Client',
  51.         => 'Expired',
  52.     ];
  53.     /**
  54.      * @Groups({"user:read"})
  55.      */
  56.     #[ORM\Id]
  57.     #[ORM\GeneratedValue]
  58.     #[ORM\Column(type'integer')]
  59.     private $id;
  60.     /**
  61.      * @Groups({"user:read"})
  62.      */
  63.     #[ORM\Column(type'string'length255nullabletrue)]
  64.     private $username;
  65.     #[ORM\Column(type'string'length255nullabletrue)]
  66.     private $password;
  67.     /**
  68.      * @Groups({"user:read"})
  69.      */
  70.     #[ORM\Column(type'string'length255nullabletrue)]
  71.     private $email;
  72.     #[ORM\Column(type'boolean'nullabletrue)]
  73.     private $isActive;
  74.     #[ORM\Column(type'string'nullabletrue)]
  75.     private $zone;
  76.     #[ORM\Column(type'json')]
  77.     private $roles = [];
  78.     #[ORM\Column(type'string'length255nullabletrue)]
  79.     private $hash;
  80.     #[ORM\Column(type'boolean'options: ['default' => false])]
  81.     private bool $admin false;
  82.     /**
  83.      * @Groups({"user:read"})
  84.      */
  85.     #[ORM\Column(type'string'length255nullabletrue)]
  86.     private $nom;
  87.     /**
  88.      * @Groups({"user:read"})
  89.      */
  90.     #[ORM\Column(type'string'length255nullabletrue)]
  91.     private $prenom;
  92.     /**
  93.      * @PhoneNumberConstraint()
  94.      *
  95.      * @Groups({"user:read"})
  96.      */
  97.     #[ORM\Column(type'string'length255nullabletrue)]
  98.     private $numtel;
  99.     #[ORM\Column(type'boolean'nullabletrue)]
  100.     private $cgu;
  101.     /**
  102.      * @var Abonnement[]|Collection
  103.      */
  104.     #[ORM\OneToMany(targetEntityAbonnement::class, mappedBy'user'cascade: ['persist'])]
  105.     #[ORM\OrderBy(['datefin' => 'DESC'])]
  106.     private Collection $abonnements;
  107.     #[ORM\Column(type'string'length255nullabletrue)]
  108.     private $civilite;
  109.     #[ORM\Column(type'datetime'nullabletrue)]
  110.     private $naissance;
  111.     /**
  112.      * @Groups({"user:read"})
  113.      */
  114.     #[ORM\Column(type'text'nullabletrue)]
  115.     private $address;
  116.     /**
  117.      * @Groups({"user:read"})
  118.      */
  119.     #[ORM\Column(type'string'length50nullabletrue)]
  120.     private $zip;
  121.     /**
  122.      * @Groups({"user:read"})
  123.      */
  124.     #[ORM\Column(type'string'length255nullabletrue)]
  125.     private $city;
  126.     #[ORM\Column(type'string'length255nullabletrue)]
  127.     private $country;
  128.     #[ORM\Column(type'boolean'nullabletrue)]
  129.     private $communication;
  130.     #[ORM\Column(type'boolean')]
  131.     private $isVerified false;
  132.     #[ORM\Column(type'datetime'nullabletrue)]
  133.     private $deletedAt;
  134.     #[ORM\Column(type'datetime'nullabletrue)]
  135.     private $datecreation;
  136.     #[ORM\Column(type'datetime'nullabletrue)]
  137.     private $datemodification;
  138.     #[ORM\Column(type'boolean'nullabletrue)]
  139.     private $optin;
  140.     #[ORM\Column(type'integer'nullabletrue)]
  141.     private $fantome;
  142.     #[ORM\Column(type'boolean'nullabletrue)]
  143.     private $getemail;
  144.     /**
  145.      * @Groups({"bike:upsert"})
  146.      */
  147.     #[ORM\Column(type'integer'nullabletrue)]
  148.     private $iduserfo;
  149.     #[ORM\Column(type'integer'nullabletrue)]
  150.     private $doubleauth;
  151.     #[ORM\OneToMany(targetEntityContact::class, mappedBy'utilisateur')]
  152.     private $contacts;
  153.     #[ORM\OneToMany(targetEntityOffre::class, mappedBy'createur')]
  154.     private $offres;
  155.     #[ORM\OneToMany(targetEntityFacture::class, mappedBy'user')]
  156.     private $factures;
  157.     #[ORM\OneToMany(targetEntityLogsUser::class, mappedBy'client')]
  158.     private $logsUsersClient;
  159.     #[ORM\OneToMany(targetEntityLogsUser::class, mappedBy'mainteneur')]
  160.     private $logsUsersMainteneur;
  161.     #[ORM\OneToMany(targetEntityLogsUser::class, mappedBy'user'cascade: ['persist'])]
  162.     private $logsUsersUser;
  163.     #[ORM\OneToMany(targetEntityLogsUser::class, mappedBy'administrateur')]
  164.     private $logsUsersAdmin;
  165.     #[ORM\Column(type'string'nullabletrue)]
  166.     private $authCode;
  167.     #[ORM\Column(type'datetime'nullabletrue)]
  168.     private $validityCode;
  169.     #[ORM\OneToMany(targetEntityNotes::class, mappedBy'User')]
  170.     private $notes;
  171.     #[ORM\JoinColumn(nullabletrue)]
  172.     #[ORM\OneToMany(targetEntityBike::class, mappedBy'user'cascade: ['persist''remove'], orphanRemovaltrue)]
  173.     private $bikes;
  174.     /**
  175.      * @var string
  176.      */
  177.     #[ORM\Column(name'id_document'type'string'length250nullabletrue)]
  178.     private $idDocument;
  179.     /**
  180.      * @var AbonnementLuckey[]|Collection
  181.      */
  182.     #[ORM\OneToMany(targetEntityAbonnementLuckey::class, mappedBy'user')]
  183.     private $abonnementsLuckey;
  184.     #[ORM\OneToOne(targetEntityUserLuckey::class, mappedBy'user'cascade: ['persist''remove'])]
  185.     private $luckeyId;
  186.     #[ORM\OneToMany(targetEntityLogsMail::class, mappedBy'user')]
  187.     private $logsMails;
  188.     #[ORM\OneToMany(targetEntityCard::class, mappedBy'user')]
  189.     private $cards;
  190.     public function __construct()
  191.     {
  192.         $this->isActive true;
  193.         $this->abonnements = new ArrayCollection();
  194.         $this->contacts = new ArrayCollection();
  195.         $this->offres = new ArrayCollection();
  196.         $this->factures = new ArrayCollection();
  197.         $this->logsUsersClient = new ArrayCollection();
  198.         $this->logsUsersMainteneur = new ArrayCollection();
  199.         $this->logsUsersUser = new ArrayCollection();
  200.         $this->logsUsersAdmin = new ArrayCollection();
  201.         $this->notes = new ArrayCollection();
  202.         $this->bikes = new ArrayCollection();
  203.         $this->abonnementsLuckey = new ArrayCollection();
  204.         $this->logsMails = new ArrayCollection();
  205.         $this->cards = new ArrayCollection();
  206.     }
  207.     public function __toString()
  208.     {
  209.         if (null !== $this->username) {
  210.             return $this->username;
  211.         }
  212.         if (null !== $this->nom) {
  213.             return $this->nom;
  214.         }
  215.         return '';
  216.     }
  217.     public function getSalt(): ?string
  218.     {
  219.         // you *may* need a real salt depending on your encoder
  220.         // see section on salt below
  221.         return null;
  222.     }
  223.     public function eraseCredentials()
  224.     {
  225.         // Nothing
  226.     }
  227.     /** @see \Serializable::serialize() */
  228.     public function serialize()
  229.     {
  230.         return serialize([
  231.             $this->id,
  232.             $this->username,
  233.             $this->password,
  234.             // see section on salt below
  235.             // $this->salt,
  236.         ]);
  237.     }
  238.     /** @see \Serializable::unserialize() */
  239.     public function unserialize($serialized)
  240.     {
  241.         list(
  242.             $this->id,
  243.             $this->username,
  244.             $this->password,
  245.             // see section on salt below
  246.             // $this->salt
  247.         ) = unserialize($serialized, ['allowed_classes' => false]);
  248.     }
  249.     /**
  250.      * The public representation of the user (e.g. a username, an email address, etc.).
  251.      *
  252.      * @see UserInterface
  253.      */
  254.     public function getUserIdentifier(): string
  255.     {
  256.         return (string) $this->username;
  257.     }
  258.     public function getId()
  259.     {
  260.         return $this->id;
  261.     }
  262.     public function getUsername(): ?string
  263.     {
  264.         return $this->username;
  265.     }
  266.     public function setUsername(?string $username): self
  267.     {
  268.         $this->username $username;
  269.         return $this;
  270.     }
  271.     public function getPassword(): ?string
  272.     {
  273.         return $this->password;
  274.     }
  275.     public function setPassword(?string $password): self
  276.     {
  277.         $this->password $password;
  278.         return $this;
  279.     }
  280.     public function getEmail(): ?string
  281.     {
  282.         return $this->email;
  283.     }
  284.     public function setEmail(?string $email): self
  285.     {
  286.         $this->email $email;
  287.         return $this;
  288.     }
  289.     public function getIsActive(): ?bool
  290.     {
  291.         return $this->isActive;
  292.     }
  293.     public function setIsActive(bool $isActive): self
  294.     {
  295.         $this->isActive $isActive;
  296.         return $this;
  297.     }
  298.     public function getZone(): ?string
  299.     {
  300.         return $this->zone;
  301.     }
  302.     public function setZone(?string $zone): self
  303.     {
  304.         $this->zone $zone;
  305.         return $this;
  306.     }
  307.     public function getHash(): ?string
  308.     {
  309.         return $this->hash;
  310.     }
  311.     public function setHash(?string $hash): self
  312.     {
  313.         $this->hash $hash;
  314.         return $this;
  315.     }
  316.     public function getAdmin(): ?bool
  317.     {
  318.         return $this->admin;
  319.     }
  320.     public function setAdmin(bool $admin): self
  321.     {
  322.         $this->admin $admin;
  323.         return $this;
  324.     }
  325.     public function getNom(): ?string
  326.     {
  327.         return $this->nom;
  328.     }
  329.     public function setNom(string $nom): self
  330.     {
  331.         $this->nom $nom;
  332.         return $this;
  333.     }
  334.     public function getPrenom(): ?string
  335.     {
  336.         return $this->prenom;
  337.     }
  338.     public function setPrenom(string $prenom): self
  339.     {
  340.         $this->prenom $prenom;
  341.         return $this;
  342.     }
  343.     public function getFullName(): string
  344.     {
  345.         return $this->prenom ' ' $this->nom;
  346.     }
  347.     public function getNumtel(): ?string
  348.     {
  349.         return $this->numtel;
  350.     }
  351.     public function setNumtel(?string $numtel): self
  352.     {
  353.         $this->numtel $numtel;
  354.         return $this;
  355.     }
  356.     public function getCgu(): ?bool
  357.     {
  358.         return $this->cgu;
  359.     }
  360.     public function setCgu(?bool $cgu): self
  361.     {
  362.         $this->cgu $cgu;
  363.         return $this;
  364.     }
  365.     /**
  366.      * @return Abonnement[]|Collection
  367.      */
  368.     public function getAbonnements(): Collection
  369.     {
  370.         return $this->abonnements;
  371.     }
  372.     /**
  373.      * If User get One active subscription return the first one it found
  374.      * If user get no active subscription return the closest one from now
  375.      * if user don't get subscription, retur null.
  376.      *
  377.      * @throws \Exception
  378.      */
  379.     public function getClosestSubscription(): ?Abonnement
  380.     {
  381.         $now = new \DateTime(
  382.             'now',
  383.             new \DateTimeZone('Europe/Paris')
  384.         );
  385.         if ($this->abonnements->isEmpty()) {
  386.             return null;
  387.         }
  388.         if (=== $this->abonnements->count()) {
  389.             return $this->abonnements->first();
  390.         }
  391.         foreach ($this->abonnements as $abo) {
  392.             if ($abo->getDatedebut() <= $now && $abo->getDatefin() >= $now) {
  393.                 return $abo;
  394.             }
  395.         }
  396.         // Find closest subscription beetween now and middle of interval
  397.         $res = [];
  398.         $nowTimestamp $now->getTimestamp();
  399.         foreach ($this->abonnements as $abo) {
  400.             $timeInterval abs(
  401.                 $nowTimestamp -
  402.                 (
  403.                     (
  404.                         $abo->getDatedebut()->getTimestamp()
  405.                         + $abo->getDatefin()->getTimestamp()
  406.                     )
  407.                     / 2
  408.                 )
  409.             );
  410.             $res[$timeInterval] = $abo;
  411.         }
  412.         ksort($res);
  413.         return current($res);
  414.     }
  415.     public function addAbonnement(Abonnement $abonnement): self
  416.     {
  417.         if (!$this->abonnements->contains($abonnement)) {
  418.             $this->abonnements->add($abonnement);
  419.             $abonnement->setUser($this);
  420.         }
  421.         return $this;
  422.     }
  423.     public function removeAbonnement(Abonnement $abonnement): self
  424.     {
  425.         if ($this->abonnements->removeElement($abonnement)) {
  426.             // set the owning side to null (unless already changed)
  427.             if ($abonnement->getUser() === $this) {
  428.                 $abonnement->setUser(null);
  429.             }
  430.         }
  431.         return $this;
  432.     }
  433.     public function getCivilite(): ?string
  434.     {
  435.         return $this->civilite;
  436.     }
  437.     public function setCivilite(?string $civilite): self
  438.     {
  439.         $this->civilite $civilite;
  440.         return $this;
  441.     }
  442.     public function getNaissance(): ?\DateTimeInterface
  443.     {
  444.         return $this->naissance;
  445.     }
  446.     public function setNaissance(?\DateTimeInterface $naissance): self
  447.     {
  448.         $this->naissance $naissance;
  449.         return $this;
  450.     }
  451.     public function getAddress(): ?string
  452.     {
  453.         return $this->address;
  454.     }
  455.     public function setAddress(?string $address): self
  456.     {
  457.         $this->address $address;
  458.         return $this;
  459.     }
  460.     public function getZip(): ?string
  461.     {
  462.         return $this->zip;
  463.     }
  464.     public function setZip(?string $zip): self
  465.     {
  466.         $this->zip $zip;
  467.         return $this;
  468.     }
  469.     public function getCity(): ?string
  470.     {
  471.         return $this->city;
  472.     }
  473.     public function setCity(?string $city): self
  474.     {
  475.         $this->city $city;
  476.         return $this;
  477.     }
  478.     public function getCountry(): ?string
  479.     {
  480.         return $this->country;
  481.     }
  482.     public function setCountry(?string $country): self
  483.     {
  484.         $this->country $country;
  485.         return $this;
  486.     }
  487.     public function getCommunication(): ?bool
  488.     {
  489.         return $this->communication;
  490.     }
  491.     public function setCommunication(?bool $communication): self
  492.     {
  493.         $this->communication $communication;
  494.         return $this;
  495.     }
  496.     public function isVerified(): bool
  497.     {
  498.         return $this->isVerified;
  499.     }
  500.     public function setIsVerified(bool $isVerified): self
  501.     {
  502.         $this->isVerified $isVerified;
  503.         return $this;
  504.     }
  505.     public function getDeletedAt(): ?\DateTimeInterface
  506.     {
  507.         return $this->deletedAt;
  508.     }
  509.     public function setDeletedAt(?\DateTimeInterface $deletedAt): self
  510.     {
  511.         $this->deletedAt $deletedAt;
  512.         return $this;
  513.     }
  514.     public function getDatecreation(): ?\DateTimeInterface
  515.     {
  516.         return $this->datecreation;
  517.     }
  518.     public function setDatecreation(?\DateTimeInterface $datecreation): self
  519.     {
  520.         $this->datecreation $datecreation;
  521.         return $this;
  522.     }
  523.     public function getDatemodification(): ?\DateTimeInterface
  524.     {
  525.         return $this->datemodification;
  526.     }
  527.     public function setDatemodification(?\DateTimeInterface $datemodification): self
  528.     {
  529.         $this->datemodification $datemodification;
  530.         return $this;
  531.     }
  532.     public function getOptin(): ?bool
  533.     {
  534.         return $this->optin;
  535.     }
  536.     public function setOptin(?bool $optin): self
  537.     {
  538.         $this->optin $optin;
  539.         return $this;
  540.     }
  541.     public function getFantome(): ?int
  542.     {
  543.         return $this->fantome;
  544.     }
  545.     public function setFantome(?int $fantome): self
  546.     {
  547.         $this->fantome $fantome;
  548.         return $this;
  549.     }
  550.     public function getRoles(): array
  551.     {
  552.         $roles $this->roles;
  553.         // guarantee every user at least has ROLE_USER
  554.         // $roles[] = 'ROLE_USER';
  555.         return array_unique($roles);
  556.     }
  557.     public function setRoles(array $roles): self
  558.     {
  559.         $this->roles $roles;
  560.         return $this;
  561.     }
  562.     public function getGetemail(): ?bool
  563.     {
  564.         return $this->getemail;
  565.     }
  566.     public function setGetemail(?bool $getemail): self
  567.     {
  568.         $this->getemail $getemail;
  569.         return $this;
  570.     }
  571.     public function getIduserfo(): ?int
  572.     {
  573.         return $this->iduserfo;
  574.     }
  575.     public function setIduserfo(?int $iduserfo): self
  576.     {
  577.         $this->iduserfo $iduserfo;
  578.         return $this;
  579.     }
  580.     public function getDoubleauth(): ?int
  581.     {
  582.         return $this->doubleauth;
  583.     }
  584.     public function setDoubleauth(?int $doubleauth): self
  585.     {
  586.         $this->doubleauth $doubleauth;
  587.         return $this;
  588.     }
  589.     /**
  590.      * @return Collection|Contact[]
  591.      */
  592.     public function getContacts(): Collection
  593.     {
  594.         return $this->contacts;
  595.     }
  596.     public function addContact(Contact $contact): self
  597.     {
  598.         if (!$this->contacts->contains($contact)) {
  599.             $this->contacts[] = $contact;
  600.             $contact->setUtilisateur($this);
  601.         }
  602.         return $this;
  603.     }
  604.     public function removeContact(Contact $contact): self
  605.     {
  606.         if ($this->contacts->removeElement($contact)) {
  607.             // set the owning side to null (unless already changed)
  608.             if ($contact->getUtilisateur() === $this) {
  609.                 $contact->setUtilisateur(null);
  610.             }
  611.         }
  612.         return $this;
  613.     }
  614.     /**
  615.      * @return Collection|Offre[]
  616.      */
  617.     public function getOffres(): Collection
  618.     {
  619.         return $this->offres;
  620.     }
  621.     public function addOffre(Offre $offre): self
  622.     {
  623.         if (!$this->offres->contains($offre)) {
  624.             $this->offres[] = $offre;
  625.             $offre->setCreateur($this);
  626.         }
  627.         return $this;
  628.     }
  629.     public function removeOffre(Offre $offre): self
  630.     {
  631.         if ($this->offres->removeElement($offre)) {
  632.             // set the owning side to null (unless already changed)
  633.             if ($offre->getCreateur() === $this) {
  634.                 $offre->setCreateur(null);
  635.             }
  636.         }
  637.         return $this;
  638.     }
  639.     /**
  640.      * @return Collection<int, Facture>
  641.      */
  642.     public function getFactures(): Collection
  643.     {
  644.         return $this->factures;
  645.     }
  646.     public function addFacture(Facture $facture): self
  647.     {
  648.         if (!$this->factures->contains($facture)) {
  649.             $this->factures[] = $facture;
  650.             $facture->setUser($this);
  651.         }
  652.         return $this;
  653.     }
  654.     public function removeFacture(Facture $facture): self
  655.     {
  656.         if ($this->factures->removeElement($facture)) {
  657.             // set the owning side to null (unless already changed)
  658.             if ($facture->getUser() === $this) {
  659.                 $facture->setUser(null);
  660.             }
  661.         }
  662.         return $this;
  663.     }
  664.     /**
  665.      * @return Collection|LogsUser[]
  666.      */
  667.     public function getLogsUsersClient(): Collection
  668.     {
  669.         return $this->logsUsersClient;
  670.     }
  671.     public function addLogsUserClient(LogsUser $logsUserClient): self
  672.     {
  673.         if (!$this->logsUsersClient->contains($logsUserClient)) {
  674.             $this->logsUsersClient[] = $logsUserClient;
  675.             $logsUserClient->setUser($this);
  676.         }
  677.         return $this;
  678.     }
  679.     public function removeLogsUserClient(LogsUser $logsUserClient): self
  680.     {
  681.         if ($this->logsUsersClient->removeElement($logsUserClient)) {
  682.             // set the owning side to null (unless already changed)
  683.             if ($logsUserClient->getUser() === $this) {
  684.                 $logsUserClient->setUser(null);
  685.             }
  686.         }
  687.         return $this;
  688.     }
  689.     /**
  690.      * @return Collection|LogsUser[]
  691.      */
  692.     public function getLogsUsersMainteneur(): Collection
  693.     {
  694.         return $this->logsUsersMainteneur;
  695.     }
  696.     public function addLogsUserMainteneur(LogsUser $logsUserMainteneur): self
  697.     {
  698.         if (!$this->logsUsersMainteneur->contains($logsUserMainteneur)) {
  699.             $this->logsUsersMainteneur[] = $logsUserMainteneur;
  700.             $logsUserMainteneur->setUser($this);
  701.         }
  702.         return $this;
  703.     }
  704.     public function removeLogsUserMainteneur(LogsUser $logsUserMainteneur): self
  705.     {
  706.         if ($this->logsUsersMainteneur->removeElement($logsUserMainteneur)) {
  707.             // set the owning side to null (unless already changed)
  708.             if ($logsUserMainteneur->getUser() === $this) {
  709.                 $logsUserMainteneur->setUser(null);
  710.             }
  711.         }
  712.         return $this;
  713.     }
  714.     /**
  715.      * @return Collection|LogsUser[]
  716.      */
  717.     public function getLogsUsersUser(): Collection
  718.     {
  719.         return $this->logsUsersUser;
  720.     }
  721.     public function addLogsUserUser(LogsUser $logsUserUser): self
  722.     {
  723.         if (!$this->logsUsersUser->contains($logsUserUser)) {
  724.             $this->logsUsersUser[] = $logsUserUser;
  725.             $logsUserUser->setUser($this);
  726.         }
  727.         return $this;
  728.     }
  729.     public function removeLogsUserUser(LogsUser $logsUserUser): self
  730.     {
  731.         if ($this->logsUsersUser->removeElement($logsUserUser)) {
  732.             // set the owning side to null (unless already changed)
  733.             if ($logsUserUser->getUser() === $this) {
  734.                 $logsUserUser->setUser(null);
  735.             }
  736.         }
  737.         return $this;
  738.     }
  739.     /**
  740.      * @return Collection|LogsUser[]
  741.      */
  742.     public function getLogsUsersAdmin(): Collection
  743.     {
  744.         return $this->logsUsersAdmin;
  745.     }
  746.     public function addLogsUserAdmin(LogsUser $logsUserAdmin): self
  747.     {
  748.         if (!$this->logsUsersAdmin->contains($logsUserAdmin)) {
  749.             $this->logsUsersAdmin[] = $logsUserAdmin;
  750.             $logsUserAdmin->setUser($this);
  751.         }
  752.         return $this;
  753.     }
  754.     public function removeLogsUserAdmin(LogsUser $logsUserAdmin): self
  755.     {
  756.         if ($this->logsUsersAdmin->removeElement($logsUserAdmin)) {
  757.             // set the owning side to null (unless already changed)
  758.             if ($logsUserAdmin->getUser() === $this) {
  759.                 $logsUserAdmin->setUser(null);
  760.             }
  761.         }
  762.         return $this;
  763.     }
  764.     /** Fonctions statiques */
  765.     /**
  766.      * Get label for specific user status code.
  767.      *
  768.      * @param int $status Status index
  769.      */
  770.     public static function getStatusLabel($status): string
  771.     {
  772.         return self::$statusLabels[$status];
  773.     }
  774.     /**
  775.      * Get user statuses array.
  776.      */
  777.     public static function getStatusLabels(): array
  778.     {
  779.         return self::$statusLabels;
  780.     }
  781.     /**
  782.      * Get label for specific client status code.
  783.      *
  784.      * @param int $status Status index
  785.      */
  786.     public static function getClientStatusLabel($status): string
  787.     {
  788.         return self::$clientStatusLabels[$status];
  789.     }
  790.     /**
  791.      * Get client statuses array.
  792.      */
  793.     public static function getClientStatusLabels(): array
  794.     {
  795.         return self::$clientStatusLabels;
  796.     }
  797.     public function isEmailAuthEnabled(): bool
  798.     {
  799.         return true// This can be a persisted field to switch email code authentication on/off
  800.     }
  801.     public function getEmailAuthRecipient(): string
  802.     {
  803.         return $this->email;
  804.     }
  805.     public function getEmailAuthCode(): string
  806.     {
  807.         if (null === $this->authCode) {
  808.             throw new \LogicException('The email authentication code was not set');
  809.         }
  810.         return $this->authCode;
  811.     }
  812.     public function setEmailAuthCode(string $authCode): void
  813.     {
  814.         $this->authCode $authCode;
  815.     }
  816.     public function deleteEmailAuthCode(): void
  817.     {
  818.         $this->authCode null;
  819.     }
  820.     public function getValidityCode(): ?\DateTimeInterface
  821.     {
  822.         return $this->validityCode;
  823.     }
  824.     public function setValidityCode(?\DateTimeInterface $validityCode): self
  825.     {
  826.         $this->validityCode $validityCode;
  827.         return $this;
  828.     }
  829.     /**
  830.      * @return Collection<int, Notes>
  831.      */
  832.     public function getNotes(): Collection
  833.     {
  834.         return $this->notes;
  835.     }
  836.     public function addNote(Notes $note): self
  837.     {
  838.         if (!$this->notes->contains($note)) {
  839.             $this->notes[] = $note;
  840.             $note->setUser($this);
  841.         }
  842.         return $this;
  843.     }
  844.     public function removeNote(Notes $note): self
  845.     {
  846.         if ($this->notes->removeElement($note)) {
  847.             // set the owning side to null (unless already changed)
  848.             if ($note->getUser() === $this) {
  849.                 $note->setUser(null);
  850.             }
  851.         }
  852.         return $this;
  853.     }
  854.     /**
  855.      * @return Bike[]|\Doctrine\Common\Collections\Collection
  856.      */
  857.     public function getBikes(): Collection
  858.     {
  859.         return $this->bikes;
  860.     }
  861.     public function addBike(Bike $bike): self
  862.     {
  863.         if (!$this->bikes->contains($bike)) {
  864.             $this->bikes[] = $bike;
  865.             $bike->setUser($this);
  866.         }
  867.         return $this;
  868.     }
  869.     public function removeBike(Bike $bike): self
  870.     {
  871.         if ($this->bikes->contains($bike)) {
  872.             $this->bikes->removeElement($bike);
  873.             // set the owning side to null (unless already changed)
  874.             if ($bike->getUser() === $this) {
  875.                 $bike->setUser(null);
  876.             }
  877.         }
  878.         return $this;
  879.     }
  880.     /**
  881.      * Get the value of idDocument.
  882.      *
  883.      * @return string
  884.      */
  885.     public function getIdDocument()
  886.     {
  887.         return $this->idDocument;
  888.     }
  889.     /**
  890.      * Set the value of idDocument.
  891.      *
  892.      * @return self
  893.      */
  894.     public function setIdDocument(?string $idDocument)
  895.     {
  896.         $this->idDocument $idDocument;
  897.         return $this;
  898.     }
  899.     /**
  900.      * Anonymize user.
  901.      *
  902.      * @return $this
  903.      */
  904.     public function anonymize(): self
  905.     {
  906.         $this->setDeletedAt(new \DateTime(
  907.             'now',
  908.             new \DateTimeZone('Europe/Paris')
  909.         ))
  910.             ->setUsername(null)
  911.             ->setPassword('')
  912.             ->setEmail('')
  913.             ->setIsActive(false)
  914.             ->setRoles(['ROLE_CLOTURE'])
  915.             ->setHash(null)
  916.             ->setAdmin(false)
  917.             ->setNom('')
  918.             ->setPrenom('')
  919.             ->setNumtel('')
  920.             ->setCgu(null)
  921.             ->setCivilite('')
  922.             ->setNaissance(null)
  923.             ->setAddress('')
  924.             ->setZip(null)
  925.             ->setCity('')
  926.             ->setCountry('')
  927.             ->setIsVerified(false)
  928.             ->setDatecreation(null)
  929.             ->setOptin(null)
  930.         ;
  931.         return $this;
  932.     }
  933.     /**
  934.      * @return Collection<int, AbonnementLuckey>
  935.      */
  936.     public function getAbonnementsLuckey(): Collection
  937.     {
  938.         return $this->abonnementsLuckey;
  939.     }
  940.     public function getLuckeyId(): ?UserLuckey
  941.     {
  942.         return $this->luckeyId;
  943.     }
  944.     public function setLuckeyId(UserLuckey $luckeyId): self
  945.     {
  946.         // set the owning side of the relation if necessary
  947.         if ($luckeyId->getUser() !== $this) {
  948.             $luckeyId->setUser($this);
  949.         }
  950.         $this->luckeyId $luckeyId;
  951.         return $this;
  952.     }
  953.     /**
  954.      * @return Collection<int, LogsMail>
  955.      */
  956.     public function getLogsMails(): Collection
  957.     {
  958.         return $this->logsMails;
  959.     }
  960.     /**
  961.      * @return Card[]|Collection
  962.      */
  963.     public function getCards(): Collection
  964.     {
  965.         return $this->cards;
  966.     }
  967.     public function addCard(Card $card): self
  968.     {
  969.         if (!$this->cards->contains($card)) {
  970.             $this->cards[] = $card;
  971.             $card->setUser($this);
  972.         }
  973.         return $this;
  974.     }
  975.     public function removeCard(Card $card): self
  976.     {
  977.         if ($this->cards->removeElement($card)) {
  978.             // set the owning side to null (unless already changed)
  979.             if ($card->getUser() === $this) {
  980.                 $card->setUser(null);
  981.             }
  982.         }
  983.         return $this;
  984.     }
  985. }