src/Entity/Users.php line 22

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\UsersRepository;
  4. use DH\Auditor\Provider\Doctrine\Auditing\Annotation\Auditable;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
  9. use Symfony\Component\Security\Core\User\UserInterface;
  10. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  11. use Symfony\Component\Validator\Constraints as Assert;
  12. /**
  13.  * @ORM\Entity(repositoryClass=UsersRepository::class)
  14.  * @UniqueEntity(fields={"mail"}, message="Un autre compte avec ce mail existe déjà.")
  15.  * @UniqueEntity(fields={"login"}, message="Un autre compte avec ce login existe déjà.")
  16.  * @UniqueEntity(fields={"telephone"}, message="Un autre compte avec ce numéro existe déjà.")
  17.  * @Auditable
  18.  */
  19. class Users implements UserInterfacePasswordAuthenticatedUserInterface
  20. {
  21.     /**
  22.      * @ORM\Id()
  23.      * @ORM\GeneratedValue()
  24.      * @ORM\Column(type="integer")
  25.      */
  26.     private $id;
  27.     /**
  28.      * @var string The hashed password
  29.      * @ORM\Column(type="string", length=4096)
  30.      */
  31.     private $username;
  32.     /**
  33.      * @ORM\Column(type="string", length=255)
  34.      * @Assert\Regex(
  35.      *     pattern="/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[!@#\$%\^&\*]).{6,}$/",
  36.      *     message="Votre mot de passe doit contenir au moins une lettre en majuscule, un chiffre, un caractère spécial parmi !@#$%^&*"
  37.      *     )
  38.      * @Assert\Length(
  39.      *     min="6",
  40.      *     max="4096",
  41.      *     minMessage="Ce champ accepte un minimum de 6 caractères",
  42.      *     maxMessage="Ce champ accepte un maximum de 4096 caractères"
  43.      * )
  44.      * @Assert\NotCompromisedPassword(
  45.      *     message="Ce mot de passe n'est pas sécurisé veuillez saisir un autre "
  46.      * )
  47.      */
  48.     private $password;
  49.     /**
  50.      * @ORM\Column(type="integer")
  51.      */
  52.     private $userType;
  53.     /**
  54.      * @ORM\Column(type="string", length=255, nullable=true, unique=true)
  55.      */
  56.     private $mail;
  57.     /**
  58.      * @ORM\Column(type="string", length=255, nullable=true, unique=true)
  59.      */
  60.     private $telephone;
  61.     /**
  62.      * @ORM\Column(type="boolean", nullable=true)
  63.      */
  64.     private $isAuthority;
  65.     /**
  66.      * @ORM\Column(type="string", length=255, nullable=true)
  67.      */
  68.     private $signature;
  69.     /**
  70.      * @ORM\Column(type="string", length=255, unique=true)
  71.      */
  72.     private $login;
  73.     /**
  74.      * @ORM\ManyToOne(targetEntity=Sites::class)
  75.      * @ORM\JoinColumn(nullable=true)
  76.      */
  77.     private $site;
  78.     /**
  79.      * @ORM\Column(type="boolean")
  80.      */
  81.     private $isDeleted;
  82.     /**
  83.      * @ORM\Column(type="boolean")
  84.      */
  85.     private $status;
  86.     /**
  87.      * @ORM\Column(type="datetime")
  88.      */
  89.     private $dateCreate;
  90.     /**
  91.      * @ORM\Column(type="datetime", nullable=true)
  92.      */
  93.     private $lastConnection;
  94.     /**
  95.      * @ORM\Column(type="string", length=255, nullable=true)
  96.      */
  97.     private $otp;
  98.     /**
  99.      * @ORM\Column(type="datetime", nullable=true)
  100.      */
  101.     private $timeOtp;
  102.     /**
  103.      * @ORM\Column(type="boolean", nullable=true)
  104.      */
  105.     private $firstLogin;
  106.     /**
  107.      * @ORM\OneToMany(targetEntity=Report::class, mappedBy="user")
  108.      */
  109.     private $reports;
  110.     // /**
  111.     //  * @ORM\Column(type="datetime", nullable=true)
  112.     //  */
  113.     // private $LastConnection;
  114.     /**
  115.      * @ORM\Column(type="datetime", nullable=true)
  116.      */
  117.     private $updatePasswordDate;
  118.     /**
  119.      * @ORM\Column(type="datetime", nullable=true)
  120.      */
  121.     private $deletedDate;
  122.     /**
  123.      * @ORM\Column(type="integer", nullable=true)
  124.      */
  125.     private $userDeleted;
  126.     /**
  127.      * @ORM\OneToMany(targetEntity=ExchangeRate::class, mappedBy="userModify")
  128.      */
  129.     private $exchangeRates;
  130.     /**
  131.      * @ORM\OneToMany(targetEntity=Livraison::class, mappedBy="createdBy")
  132.      */
  133.     private $livraisons;
  134.     /**
  135.      * @ORM\Column(type="string", length=255)
  136.      */
  137.     private $uID;
  138.     public function __construct()
  139.     {
  140.         $this->username "";
  141.         $this->status true;
  142.         $this->isDeleted false;
  143.         $this->dateCreate = new \DateTime();
  144.         $this->reports = new ArrayCollection();
  145.         $this->exchangeRates = new ArrayCollection();
  146.         $this->livraisons = new ArrayCollection();
  147.     }
  148.     public function getId(): ?int
  149.     {
  150.         return $this->id;
  151.     }
  152.     /**
  153.      * A visual identifier that represents this user.
  154.      *
  155.      * @see UserInterface
  156.      */
  157.     public function getUsername(): ?string
  158.     {
  159.         return $this->username;
  160.     }
  161.     public function setUsername(string $username): self
  162.     {
  163.         $this->username $username;
  164.         return $this;
  165.     }
  166.     public function getLogin(): ?string
  167.     {
  168.         return $this->login;
  169.     }
  170.     public function setLogin(string $login): self
  171.     {
  172.         $this->login $login;
  173.         return $this;
  174.     }
  175.     /**
  176.      * @see UserInterface
  177.      */
  178.     public function getPassword(): ?string
  179.     {
  180.         return $this->password;
  181.     }
  182.     public function setPassword(string $password): self
  183.     {
  184.         $this->password $password;
  185.         return $this;
  186.     }
  187.     /**
  188.      * @see UserInterface
  189.      */
  190.     public function getSalt() : ?string
  191.     {
  192.         // not needed when using the "bcrypt" algorithm in security.yaml
  193.         return null;
  194.     }
  195.     /**
  196.      * @see UserInterface
  197.      */
  198.     public function eraseCredentials()
  199.     {
  200.         // If you store any temporary, sensitive data on the user, clear it here
  201.         // $this->plainPassword = null;
  202.     }
  203.     public function getUserType(): ?int
  204.     {
  205.         return $this->userType;
  206.     }
  207.     public function setUserType(int $userType): self
  208.     {
  209.         $this->userType $userType;
  210.         return $this;
  211.     }
  212.     public function getMail(): ?string
  213.     {
  214.         return $this->mail;
  215.     }
  216.     public function setMail(?string $mail): self
  217.     {
  218.         $this->mail $mail;
  219.         return $this;
  220.     }
  221.     public function getTelephone(): ?string
  222.     {
  223.         return $this->telephone;
  224.     }
  225.     public function setTelephone(?string $telephone): self
  226.     {
  227.         $this->telephone $telephone;
  228.         return $this;
  229.     }
  230.     public function getIsAuthority(): ?bool
  231.     {
  232.         return $this->isAuthority;
  233.     }
  234.     public function setIsAuthority(?bool $isAuthority): self
  235.     {
  236.         $this->isAuthority $isAuthority;
  237.         return $this;
  238.     }
  239.     public function getSignature(): ?string
  240.     {
  241.         return $this->signature;
  242.     }
  243.     public function setSignature(?string $signature): self
  244.     {
  245.         $this->signature $signature;
  246.         return $this;
  247.     }
  248.     public function getSite(): ?Sites
  249.     {
  250.         return $this->site;
  251.     }
  252.     public function setSite(?Sites $site): self
  253.     {
  254.         $this->site $site;
  255.         return $this;
  256.     }
  257.     public function getIsDeleted(): ?bool
  258.     {
  259.         return $this->isDeleted;
  260.     }
  261.     public function setIsDeleted(bool $isDeleted): self
  262.     {
  263.         $this->isDeleted $isDeleted;
  264.         return $this;
  265.     }
  266.     public function getRoles(): ?array
  267.     {
  268.         return ['ROLE_USER'];
  269.     }
  270.     public function getStatus(): ?bool
  271.     {
  272.         return $this->status;
  273.     }
  274.     public function setStatus(bool $status): self
  275.     {
  276.         $this->status $status;
  277.         return $this;
  278.     }
  279.     public function getLastConnection(): ?\DateTimeInterface
  280.     {
  281.         return $this->lastConnection;
  282.     }
  283.     public function setLastConnection(?\DateTimeInterface $lastConnection): self
  284.     {
  285.         $this->lastConnection $lastConnection;
  286.         return $this;
  287.     }
  288.     public function getDateCreate(): ?\DateTimeInterface
  289.     {
  290.         return $this->dateCreate;
  291.     }
  292.     public function setDateCreate(\DateTimeInterface $dateCreate): self
  293.     {
  294.         $this->dateCreate $dateCreate;
  295.         return $this;
  296.     }
  297.     public function getOtp(): ?string
  298.     {
  299.         return $this->otp;
  300.     }
  301.     public function setOtp(?string $otp): self
  302.     {
  303.         $this->otp $otp;
  304.         return $this;
  305.     }
  306.     public function getTimeOtp(): ?\DateTimeInterface
  307.     {
  308.         return $this->timeOtp;
  309.     }
  310.     public function setTimeOtp(?\DateTimeInterface $timeOtp): self
  311.     {
  312.         $this->timeOtp $timeOtp;
  313.         return $this;
  314.     }
  315.     public function getFirstLogin(): ?bool
  316.     {
  317.         return $this->firstLogin;
  318.     }
  319.     public function setFirstLogin(?bool $firstLogin): self
  320.     {
  321.         $this->firstLogin $firstLogin;
  322.         return $this;
  323.     }
  324.     /**
  325.      * @return Collection|Report[]
  326.      */
  327.     public function getReports(): Collection
  328.     {
  329.         return $this->reports;
  330.     }
  331.     public function addReport(Report $report): self
  332.     {
  333.         if (!$this->reports->contains($report)) {
  334.             $this->reports[] = $report;
  335.             $report->setUser($this);
  336.         }
  337.         return $this;
  338.     }
  339.     public function removeReport(Report $report): self
  340.     {
  341.         if ($this->reports->removeElement($report)) {
  342.             // set the owning side to null (unless already changed)
  343.             if ($report->getUser() === $this) {
  344.                 $report->setUser(null);
  345.             }
  346.         }
  347.         return $this;
  348.     }
  349.     public function getUpdatePasswordDate(): ?\DateTimeInterface
  350.     {
  351.         return $this->updatePasswordDate;
  352.     }
  353.     public function setUpdatePasswordDate(?\DateTimeInterface $updatePasswordDate): self
  354.     {
  355.         $this->updatePasswordDate $updatePasswordDate;
  356.         return $this;
  357.     }
  358.     public function getDeletedDate(): ?\DateTimeInterface
  359.     {
  360.         return $this->deletedDate;
  361.     }
  362.     public function setDeletedDate(?\DateTimeInterface $deletedDate): self
  363.     {
  364.         $this->deletedDate $deletedDate;
  365.         return $this;
  366.     }
  367.     public function getUserDeleted(): ?int
  368.     {
  369.         return $this->userDeleted;
  370.     }
  371.     public function setUserDeleted(?int $userDeleted): self
  372.     {
  373.         $this->userDeleted $userDeleted;
  374.         return $this;
  375.     }
  376.     /**
  377.      * @return Collection<int, ExchangeRate>
  378.      */
  379.     public function getExchangeRates(): Collection
  380.     {
  381.         return $this->exchangeRates;
  382.     }
  383.     public function addExchangeRate(ExchangeRate $exchangeRate): self
  384.     {
  385.         if (!$this->exchangeRates->contains($exchangeRate)) {
  386.             $this->exchangeRates[] = $exchangeRate;
  387.             $exchangeRate->setUserModify($this);
  388.         }
  389.         return $this;
  390.     }
  391.     public function removeExchangeRate(ExchangeRate $exchangeRate): self
  392.     {
  393.         if ($this->exchangeRates->removeElement($exchangeRate)) {
  394.             // set the owning side to null (unless already changed)
  395.             if ($exchangeRate->getUserModify() === $this) {
  396.                 $exchangeRate->setUserModify(null);
  397.             }
  398.         }
  399.         return $this;
  400.     }
  401.     public function getUserIdentifier(): string
  402.     {
  403.         // Implement the method to return the user identifier
  404.         return $this->login;
  405.     }
  406.     /**
  407.      * @return Collection<int, Livraison>
  408.      */
  409.     public function getLivraisons(): Collection
  410.     {
  411.         return $this->livraisons;
  412.     }
  413.     public function addLivraison(Livraison $livraison): self
  414.     {
  415.         if (!$this->livraisons->contains($livraison)) {
  416.             $this->livraisons[] = $livraison;
  417.             $livraison->setCreatedBy($this);
  418.         }
  419.         return $this;
  420.     }
  421.     public function removeLivraison(Livraison $livraison): self
  422.     {
  423.         if ($this->livraisons->removeElement($livraison)) {
  424.             // set the owning side to null (unless already changed)
  425.             if ($livraison->getCreatedBy() === $this) {
  426.                 $livraison->setCreatedBy(null);
  427.             }
  428.         }
  429.         return $this;
  430.     }
  431.     public function getUID(): ?string
  432.     {
  433.         return $this->uID;
  434.     }
  435.     public function setUID(string $uID): self
  436.     {
  437.         $this->uID $uID;
  438.         return $this;
  439.     }
  440. }