src/Entity/User.php line 20

  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\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
  8. use Symfony\Component\Security\Core\User\UserInterface;
  9. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  10. use Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface;
  11. use Symfony\Component\Validator\Constraints as Assert;
  12. use OpenApi\Attributes as OA;
  13. /*#[UniqueEntity('email')]*/
  14. #[ORM\Entity(repositoryClassUserRepository::class)]
  15. #[ORM\EntityListeners(['App\EntityListener\UserListener'])]
  16. class User implements UserInterfacePasswordAuthenticatedUserInterface
  17. {
  18.     #[ORM\Id]
  19.     #[ORM\GeneratedValue]
  20.     #[ORM\Column(type'integer')]
  21.     private ?int $id;
  22.     #[ORM\Column(type'string'length180nullabletrue)]
  23.     #[Assert\Email()]
  24.     #[Assert\Length(min2max180)]
  25.     private string $email;
  26.     #[ORM\Column(type'json')]
  27.     #[Assert\NotNull()]
  28.     #[OA\Property(type"array"items: new OA\Items(type"string"))]
  29.     private array $roles = [];
  30.     private ?string $plainPassword null;
  31.     #[ORM\Column(type'string')]
  32.     #[Assert\NotBlank()]
  33.     // On init avec une chaine aléatoire
  34.     private string $password '643dfce2662dce89fbbb45cadaece3e0444144149e46f14232b00686e24cdf6e';
  35.     #[ORM\Column(type'datetime_immutable')]
  36.     #[Assert\NotNull()]
  37.     private \DateTimeImmutable $createdAt;
  38.     #[ORM\Column(type'datetime_immutable')]
  39.     #[Assert\NotNull()]
  40.     private \DateTimeImmutable $updatedAt;
  41.     #[ORM\Column]
  42.     private ?bool $enabled null;
  43.     #[ORM\Column(length255)]
  44.     private ?string $firstName null;
  45.     #[ORM\Column(length255)]
  46.     private ?string $lastName null;
  47.     #[ORM\Column(nullabletrue)]
  48.     private ?\DateTimeImmutable $connectedAt null;
  49.     /*#[ORM\Column(length: 50, unique: true)]
  50.     private ?string $identifier = null;*/
  51.     #[ORM\Column(nullabletrue)]
  52.     private ?int $societe null;
  53.     #[ORM\Column(nullabletrue)]
  54.     private ?int $code_regroupement null;
  55.     #[ORM\Column(nullabletrue)]
  56.     private ?int $code_client null;
  57.     #[ORM\Column(length250nullabletrue)]
  58.     private ?string $type_login null;
  59.     #[ORM\Column(length250nullabletrue)]
  60.     private ?string $profil_alias null;
  61.     #[ORM\Column(length250nullabletrue)]
  62.     private ?string $profil_nom null;
  63.     #[ORM\Column(length250nullabletrue)]
  64.     private ?string $email_client null;
  65.     #[ORM\Column(length250nullabletrue)]
  66.     private ?string $nom null;
  67.     #[ORM\Column(length250)]
  68.     private ?string $commande null;
  69.     #[ORM\Column(length250nullabletrue)]
  70.     private ?string $maj_cde null;
  71.     #[ORM\Column(length250nullabletrue)]
  72.     private ?string $valideur_cde null;
  73.     #[ORM\Column(length250nullabletrue)]
  74.     private ?string $catalogue_general null;
  75.     #[ORM\Column(length250nullabletrue)]
  76.     private ?string $logo_client null;
  77.     #[ORM\Column(length250nullabletrue)]
  78.     private ?string $impu_web null;
  79.     #[ORM\Column(length250nullabletrue)]
  80.     private ?string $blocage_cde null;
  81.     #[ORM\Column(length250nullabletrue)]
  82.     private ?string $reference_cde null;
  83.     #[ORM\Column(length250nullabletrue)]
  84.     private ?string $envoi_mail null;
  85.     #[ORM\Column(nullabletrue)]
  86.     private ?float $max_ht_cde null;
  87.     #[ORM\Column(nullabletrue)]
  88.     private ?float $montant_frais_de_port null;
  89.     #[ORM\Column(nullabletrue)]
  90.     private ?float $seuil_appli_du_port null;
  91.     #[ORM\Column(length250nullabletrue)]
  92.     private ?string $devise null;
  93.     #[ORM\ManyToOne(inversedBy'users')]
  94.     private ?Vendeur $vendeur null;
  95.     #[ORM\OneToMany(mappedBy'user'targetEntityTarif::class)]
  96.     private Collection $tarifs;
  97.     #[ORM\OneToMany(mappedBy'commandepar'targetEntityTarif::class)]
  98.     private Collection $commandepar;
  99.     #[ORM\OneToMany(mappedBy'commandepar'targetEntityCommande400::class)]
  100.     private Collection $commande400s;
  101.     #[ORM\ManyToOne(inversedBy'users')]
  102.     private ?AssistanteCommerciale $assistante null;                                                                                                                                              
  103.     public function __construct(UserPasswordHasherInterface $passwordHasher)
  104.     {
  105.         //Initilisation du mot de passe 
  106.         $this->setPlainPassword(bin2hex(random_bytes((64-(64%2))/2)));
  107.         $this->password $passwordHasher->hashPassword(
  108.             $this,
  109.             $this->getPlainPassword()
  110.         );
  111.         $this->createdAt = new \DateTimeImmutable();
  112.         $this->updatedAt = new \DateTimeImmutable();
  113.         $this->tarifs = new ArrayCollection();
  114.         $this->commandepar = new ArrayCollection();
  115.         $this->commande400s = new ArrayCollection();
  116.     }
  117.     public function getId(): ?int
  118.     {
  119.         return $this->id;
  120.     }
  121.     public function getEmail(): ?string
  122.     {
  123.         return $this->email;
  124.     }
  125.     public function setEmail(string $email): self
  126.     {
  127.         $this->email $email;
  128.         return $this;
  129.     }
  130.     /**
  131.      * A visual identifier that represents this user.
  132.      *
  133.      * @see UserInterface
  134.      */
  135.     public function getUserIdentifier(): string
  136.     {
  137.         return (string) $this->code_client;
  138.     }
  139.     /**
  140.      * @see UserInterface
  141.      */
  142.     public function getRoles(): array
  143.     {
  144.         $roles $this->roles;
  145.         if (count($roles) === )
  146.             $roles[] = 'ROLE_USER';
  147.         return array_unique($roles);
  148.     }
  149.     /**
  150.      * Test si l'utilisateur possède le rôle ADMIN
  151.      */
  152.     public function isAdmin(): bool
  153.     {
  154.         return in_array('ROLE_ADMIN'$this->getRoles());
  155.     }
  156.     public function setRoles(array $roles): self
  157.     {
  158.         $this->roles $roles;
  159.         return $this;
  160.     }
  161.     /**
  162.      * Get the value of plainPassword
  163.      */
  164.     public function getPlainPassword()
  165.     {
  166.         return $this->plainPassword;
  167.     }
  168.     
  169.     /**
  170.      * Set the value of plainPassword
  171.      *
  172.      * @return  self
  173.      */
  174.     public function setPlainPassword($plainPassword)
  175.     {
  176.         $this->plainPassword $plainPassword;
  177.         return $this;
  178.     }
  179.     /**
  180.      * @see PasswordAuthenticatedUserInterface
  181.      */
  182.     public function getPassword(): string
  183.     {
  184.         return $this->password;
  185.     }
  186.     public function setPassword(string $password): self
  187.     {
  188.         $this->password $password;
  189.         return $this;
  190.     }
  191.     /**
  192.      * @see UserInterface
  193.      */
  194.     public function eraseCredentials()
  195.     {
  196.         // If you store any temporary, sensitive data on the user, clear it here
  197.         // $this->plainPassword = null;
  198.     }
  199.     public function getCreatedAt(): ?\DateTimeImmutable
  200.     {
  201.         return $this->createdAt;
  202.     }
  203.     public function setCreatedAt(\DateTimeImmutable $createdAt): self
  204.     {
  205.         $this->createdAt $createdAt;
  206.         return $this;
  207.     }
  208.     public function getUpdatedAt(): ?\DateTimeImmutable
  209.     {
  210.         return $this->updatedAt;
  211.     }
  212.     public function setUpdatedAt(\DateTimeImmutable $updatedAt): self
  213.     {
  214.         $this->updatedAt $updatedAt;
  215.         return $this;
  216.     }
  217.     public function isEnabled(): ?bool
  218.     {
  219.         return $this->enabled;
  220.     }
  221.     public function setEnabled(bool $enabled): self
  222.     {
  223.         $this->enabled $enabled;
  224.         return $this;
  225.     }
  226.     public function switchEnabled(): self
  227.     {
  228.         $enabled = ($this->enabled == true) ? 1;
  229.         $this->enabled $enabled;
  230.         return $this;
  231.     }
  232.     public function getFirstName(): ?string
  233.     {
  234.         return $this->firstName;
  235.     }
  236.     public function setFirstName(string $firstName): self
  237.     {
  238.         $this->firstName $firstName;
  239.         return $this;
  240.     }
  241.     public function getLastName(): ?string
  242.     {
  243.         return $this->lastName;
  244.     }
  245.     public function getFullName(): ?string
  246.     {
  247.         return $this->firstName ' ' strtoupper($this->lastName);
  248.     }
  249.     public function setLastName(string $lastName): self
  250.     {
  251.         $this->lastName $lastName;
  252.         return $this;
  253.     }
  254.     public function getConnectedAt(): ?\DateTimeImmutable
  255.     {
  256.         return $this->connectedAt;
  257.     }
  258.     public function setConnectedAt(?\DateTimeImmutable $connectedAt): self
  259.     {
  260.         $this->connectedAt $connectedAt;
  261.         return $this;
  262.     }
  263.     /*public function getIdentifier(): ?string
  264.     {
  265.         return $this->identifier;
  266.     }
  267.     public function setIdentifier(string $identifier): self
  268.     {
  269.         $this->identifier = $identifier;
  270.         return $this;
  271.     }*/
  272.     public function getSociete(): ?int
  273.     {
  274.         return $this->societe;
  275.     }
  276.     public function setSociete(?int $societe): self
  277.     {
  278.         $this->societe $societe;
  279.         return $this;
  280.     }
  281.     public function getCodeRegroupement(): ?int
  282.     {
  283.         return $this->code_regroupement;
  284.     }
  285.     public function setCodeRegroupement(?int $code_regroupement): self
  286.     {
  287.         $this->code_regroupement $code_regroupement;
  288.         return $this;
  289.     }
  290.     /**
  291.      * A visual identifier that represents this user.
  292.      *
  293.      * @see UserInterface
  294.      */
  295.     public function getCodeClient(): ?int
  296.     {
  297.         return $this->code_client;
  298.     }
  299.     public function setCodeClient(?int $code_client): self
  300.     {
  301.         $this->code_client $code_client;
  302.         return $this;
  303.     }
  304.     public function getTypeLogin(): ?string
  305.     {
  306.         return $this->type_login;
  307.     }
  308.     public function setTypeLogin(?string $type_login): self
  309.     {
  310.         $this->type_login $type_login;
  311.         return $this;
  312.     }
  313.     public function getProfilAlias(): ?string
  314.     {
  315.         return $this->profil_alias;
  316.     }
  317.     public function setProfilAlias(?string $profil_alias): self
  318.     {
  319.         $this->profil_alias $profil_alias;
  320.         return $this;
  321.     }
  322.     public function getProfilNom(): ?string
  323.     {
  324.         return $this->profil_nom;
  325.     }
  326.     public function setProfilNom(?string $profil_nom): self
  327.     {
  328.         $this->profil_nom $profil_nom;
  329.         return $this;
  330.     }
  331.     public function getEmailClient(): ?string
  332.     {
  333.         return $this->email_client;
  334.     }
  335.     public function setEmailClient(?string $email_client): self
  336.     {
  337.         $this->email_client $email_client;
  338.         return $this;
  339.     }
  340.     public function getNom(): ?string
  341.     {
  342.         return $this->nom;
  343.     }
  344.     public function setNom(?string $nom): self
  345.     {
  346.         $this->nom $nom;
  347.         return $this;
  348.     }
  349.     public function getCommande(): ?string
  350.     {
  351.         return $this->commande;
  352.     }
  353.     public function setCommande(string $commande): self
  354.     {
  355.         $this->commande $commande;
  356.         return $this;
  357.     }
  358.     public function getMajCde(): ?string
  359.     {
  360.         return $this->maj_cde;
  361.     }
  362.     public function setMajCde(?string $maj_cde): self
  363.     {
  364.         $this->maj_cde $maj_cde;
  365.         return $this;
  366.     }
  367.     public function getValideurCde(): ?string
  368.     {
  369.         return $this->valideur_cde;
  370.     }
  371.     public function setValideurCde(?string $valideur_cde): self
  372.     {
  373.         $this->valideur_cde $valideur_cde;
  374.         return $this;
  375.     }
  376.     public function getCatalogueGeneral(): ?string
  377.     {
  378.         return $this->catalogue_general;
  379.     }
  380.     public function setCatalogueGeneral(?string $catalogue_general): self
  381.     {
  382.         $this->catalogue_general $catalogue_general;
  383.         return $this;
  384.     }
  385.     public function getLogoClient(): ?string
  386.     {
  387.         return $this->logo_client;
  388.     }
  389.     public function setLogoClient(?string $logo_client): self
  390.     {
  391.         $this->logo_client $logo_client;
  392.         return $this;
  393.     }
  394.     public function getImpuWeb(): ?string
  395.     {
  396.         return $this->impu_web;
  397.     }
  398.     public function setImpuWeb(?string $impu_web): self
  399.     {
  400.         $this->impu_web $impu_web;
  401.         return $this;
  402.     }
  403.     public function getBlocageCde(): ?string
  404.     {
  405.         return $this->blocage_cde;
  406.     }
  407.     public function setBlocageCde(?string $blocage_cde): self
  408.     {
  409.         $this->blocage_cde $blocage_cde;
  410.         return $this;
  411.     }
  412.     public function getReferenceCde(): ?string
  413.     {
  414.         return $this->reference_cde;
  415.     }
  416.     public function setReferenceCde(?string $reference_cde): self
  417.     {
  418.         $this->reference_cde $reference_cde;
  419.         return $this;
  420.     }
  421.     public function getEnvoiMail(): ?string
  422.     {
  423.         return $this->envoi_mail;
  424.     }
  425.     public function setEnvoiMail(?string $envoi_mail): self
  426.     {
  427.         $this->envoi_mail $envoi_mail;
  428.         return $this;
  429.     }
  430.     public function getMaxHtCde(): ?float
  431.     {
  432.         return $this->max_ht_cde;
  433.     }
  434.     public function setMaxHtCde(?float $max_ht_cde): self
  435.     {
  436.         $this->max_ht_cde $max_ht_cde;
  437.         return $this;
  438.     }
  439.     public function getMontantFraisDePort(): ?float
  440.     {
  441.         return $this->montant_frais_de_port;
  442.     }
  443.     public function setMontantFraisDePort(?float $montant_frais_de_port): self
  444.     {
  445.         $this->montant_frais_de_port $montant_frais_de_port;
  446.         return $this;
  447.     }
  448.     public function getSeuilAppliDuPort(): ?float
  449.     {
  450.         return $this->seuil_appli_du_port;
  451.     }
  452.     public function setSeuilAppliDuPort(?float $seuil_appli_du_port): self
  453.     {
  454.         $this->seuil_appli_du_port $seuil_appli_du_port;
  455.         return $this;
  456.     }
  457.     public function getDevise(): ?string
  458.     {
  459.         return $this->devise;
  460.     }
  461.     public function setDevise(?string $devise): self
  462.     {
  463.         $this->devise $devise;
  464.         return $this;
  465.     }
  466.     public function getVendeur(): ?Vendeur
  467.     {
  468.         return $this->vendeur;
  469.     }
  470.     public function setVendeur(?Vendeur $vendeur): self
  471.     {
  472.         $this->vendeur $vendeur;
  473.         return $this;
  474.     }
  475.     /**
  476.      * @return Collection<int, Tarif>
  477.      */
  478.     public function getTarifs(): Collection
  479.     {
  480.         return $this->tarifs;
  481.     }
  482.     public function addTarif(Tarif $tarif): self
  483.     {
  484.         if (!$this->tarifs->contains($tarif)) {
  485.             $this->tarifs->add($tarif);
  486.             $tarif->setUser($this);
  487.         }
  488.         return $this;
  489.     }
  490.     public function removeTarif(Tarif $tarif): self
  491.     {
  492.         if ($this->tarifs->removeElement($tarif)) {
  493.             // set the owning side to null (unless already changed)
  494.             if ($tarif->getUser() === $this) {
  495.                 $tarif->setUser(null);
  496.             }
  497.         }
  498.         return $this;
  499.     }
  500.     /**
  501.      * @return Collection<int, Tarif>
  502.      */
  503.     public function getCommandepar(): Collection
  504.     {
  505.         return $this->commandepar;
  506.     }
  507.     public function addCommandepar(Tarif $commandepar): self
  508.     {
  509.         if (!$this->commandepar->contains($commandepar)) {
  510.             $this->commandepar->add($commandepar);
  511.             $commandepar->setCommandepar($this);
  512.         }
  513.         return $this;
  514.     }
  515.     public function removeCommandepar(Tarif $commandepar): self
  516.     {
  517.         if ($this->commandepar->removeElement($commandepar)) {
  518.             // set the owning side to null (unless already changed)
  519.             if ($commandepar->getCommandepar() === $this) {
  520.                 $commandepar->setCommandepar(null);
  521.             }
  522.         }
  523.         return $this;
  524.     }
  525.     /**
  526.      * @return Collection<int, Commande400>
  527.      */
  528.     public function getCommande400s(): Collection
  529.     {
  530.         return $this->commande400s;
  531.     }
  532.     public function addCommande400(Commande400 $commande400): self
  533.     {
  534.         if (!$this->commande400s->contains($commande400)) {
  535.             $this->commande400s->add($commande400);
  536.             $commande400->setCommandepar($this);
  537.         }
  538.         return $this;
  539.     }
  540.     public function removeCommande400(Commande400 $commande400): self
  541.     {
  542.         if ($this->commande400s->removeElement($commande400)) {
  543.             // set the owning side to null (unless already changed)
  544.             if ($commande400->getCommandepar() === $this) {
  545.                 $commande400->setCommandepar(null);
  546.             }
  547.         }
  548.         return $this;
  549.     }
  550.     public function getAssistante(): ?AssistanteCommerciale
  551.     {
  552.         return $this->assistante;
  553.     }
  554.     public function setAssistante(?AssistanteCommerciale $assistante): self
  555.     {
  556.         $this->assistante $assistante;
  557.         return $this;
  558.     }
  559. }