src/Entity/User.php line 20

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\UserRepository;
  4. use DateInterval;
  5. use DateTime;
  6. use DateTimeImmutable;
  7. use Doctrine\Common\Collections\ArrayCollection;
  8. use Doctrine\Common\Collections\Collection;
  9. use Doctrine\DBAL\Types\Types;
  10. use Doctrine\ORM\Mapping as ORM;
  11. use PhpParser\Node\Expr\FuncCall;
  12. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  13. use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
  14. use Symfony\Component\Security\Core\User\UserInterface;
  15. #[ORM\Entity(repositoryClassUserRepository::class)]
  16. #[UniqueEntity(fields: ['email'], message'Cette adresse mail est déjà utilisée')]
  17. class User implements UserInterfacePasswordAuthenticatedUserInterface
  18. {
  19.     const ROLE_USER = ['ROLE_USER'];
  20.     const ROLE_COMMERCIAL = ['ROLE_COMMERCIAL'];
  21.     const ROLE_GARAGISTE = ['ROLE_GARAGISTE'];
  22.     const ROLE_RESPONSABLE_GARAGE = ['ROLE_RESPONSABLE_GARAGE'];
  23.     const ROLE_ADMIN = ['ROLE_ADMIN'];
  24.     #[ORM\Id]
  25.     #[ORM\GeneratedValue]
  26.     #[ORM\Column]
  27.     private ?int $id null;
  28.     #[ORM\Column(length180uniquetrue)]
  29.     private ?string $email null;
  30.     #[ORM\Column]
  31.     private array $roles = [];
  32.     /**
  33.      * @var string The hashed password
  34.      */
  35.     #[ORM\Column]
  36.     private ?string $password null;
  37.     #[ORM\Column(length50nullabletrue)]
  38.     private ?string $nom null;
  39.     #[ORM\Column(length50nullabletrue)]
  40.     private ?string $prenom null;
  41.     
  42.     #[ORM\Column(length100)]
  43.     private ?string $adresse null;
  44.     #[ORM\Column(length15nullabletrue)]  
  45.     private ?string $sexe null;  
  46.     #[ORM\Column]
  47.     private ?\DateTimeImmutable $createdAt null;
  48.     #[ORM\Column]
  49.     private ?\DateTimeImmutable $updatedAt null;
  50.     #[ORM\Column(length15nullabletrue)]
  51.     private ?string $tel null;  
  52.     #[ORM\Column(length255nullabletrue)]
  53.     private ?string $tokenRegistration null;
  54.     #[ORM\Column(typeTypes::DATETIME_MUTABLE)]
  55.     private ?\DateTimeInterface $tokenRegistrationLifeTime null;
  56.     #[ORM\Column]
  57.     private ?bool $isVerified false;
  58.     #[ORM\OneToMany(mappedBy'user'targetEntityJobCard::class)]
  59.     private Collection $jobcards;
  60.     #[ORM\Column(length255nullabletrue)]
  61.     private ?string $typeClient null;
  62.     #[ORM\Column(length255nullabletrue)]
  63.     private ?string $rccmFileName null;
  64.     #[ORM\Column(length255nullabletrue)]
  65.     private ?string $rccm null;
  66.     #[ORM\OneToMany(mappedBy'user'targetEntityHistorique::class)]
  67.     private Collection $historiques;
  68.     #[ORM\OneToMany(mappedBy'responsable'targetEntityTraveaux::class)]
  69.     private Collection $traveauxes;
  70.     #[ORM\Column(length50nullabletrue)]
  71.     private ?string $profil null;
  72.     #[ORM\Column(length255nullabletrue)]
  73.     private ?string $NomCompletCommercial null;
  74.     #[ORM\Column(length255nullabletrue)]
  75.     private ?string $nomEtreprise null;
  76.     #[ORM\Column(length255nullabletrue)]
  77.     private ?string $statusEntreprise null;
  78.     public function getId(): ?int
  79.     {
  80.         return $this->id;
  81.     }
  82.     public function __construct()
  83.     {
  84.         $this->createdAt = new  DateTimeImmutable();
  85.         $this->updatedAt = new DateTimeImmutable();
  86.         $this->isVerified false;
  87.         $this->tokenRegistrationLifeTime = (new DateTime('now'))->add(new DateInterval("P1D"));
  88.         $this->jobcards = new ArrayCollection();
  89.         $this->historiques = new ArrayCollection();
  90.         $this->traveauxes = new ArrayCollection();
  91.     }
  92.     public function getEmail(): ?string
  93.     {
  94.         return $this->email;
  95.     }
  96.     public function setEmail(string $email): static
  97.     {
  98.         $this->email $email;
  99.         return $this;
  100.     }
  101.     /**
  102.      * A visual identifier that represents this user.
  103.      *
  104.      * @see UserInterface
  105.      */
  106.     public function getUserIdentifier(): string
  107.     {
  108.         return (string) $this->email;
  109.     }
  110.     /**
  111.      * @see UserInterface
  112.      */
  113.     public function getRoles(): array
  114.     {
  115.         $roles $this->roles;
  116.         // guarantee every user at least has ROLE_USER
  117.         $roles[] = 'ROLE_USER';
  118.         return array_unique($roles);
  119.     }
  120.     public function setRoles(array $roles): static
  121.     {
  122.         $this->roles $roles;
  123.         return $this;
  124.     }
  125.     /**
  126.      * @see PasswordAuthenticatedUserInterface
  127.      */
  128.     public function getPassword(): string
  129.     {
  130.         return $this->password;
  131.     }
  132.     public function setPassword(string $password): static
  133.     {
  134.         $this->password $password;
  135.         return $this;
  136.     }
  137.     /**
  138.      * @see UserInterface
  139.      */
  140.     public function eraseCredentials(): void
  141.     {
  142.         // If you store any temporary, sensitive data on the user, clear it here
  143.         // $this->plainPassword = null;
  144.     }
  145.     public function getNom(): ?string
  146.     {
  147.         return $this->nom;
  148.     }
  149.     public function setNom(string $nom): static
  150.     {
  151.         $this->nom $nom;
  152.         return $this;
  153.     }
  154.     public function getPrenom(): ?string
  155.     {
  156.         return $this->prenom;
  157.     }
  158.     public function setPrenom(?string $prenom): static
  159.     {
  160.         $this->prenom $prenom;
  161.         return $this;
  162.     }
  163.     public function getAdresse(): ?string
  164.     {
  165.         return $this->adresse;
  166.     }
  167.     public function setAdresse(string $adresse): static
  168.     {
  169.         $this->adresse $adresse;
  170.         return $this;
  171.     }
  172.     public function getSexe(): ?string
  173.     {
  174.         return $this->sexe;
  175.     }
  176.     public function setSexe(?string $sexe): static
  177.     {
  178.         $this->sexe $sexe;
  179.         return $this;
  180.     }
  181.     public function getCreatedAt(): ?\DateTimeImmutable
  182.     {
  183.         return $this->createdAt;
  184.     }
  185.     public function setCreatedAt(\DateTimeImmutable $createdAt): static
  186.     {
  187.         $this->createdAt $createdAt;
  188.         return $this;
  189.     }
  190.     public function getUpdatedAt(): ?\DateTimeImmutable
  191.     {
  192.         return $this->updatedAt;
  193.     }
  194.     public function setUpdatedAt(\DateTimeImmutable $updatedAt): static
  195.     {
  196.         $this->updatedAt $updatedAt;
  197.         return $this;
  198.     }
  199.     public function getTel(): ?string
  200.     {
  201.         return $this->tel;
  202.     }
  203.     public function setTel(?string $tel): static
  204.     {
  205.         $this->tel $tel;
  206.         return $this;
  207.     }
  208.     public function getTokenRegistration(): ?string
  209.     {
  210.         return $this->tokenRegistration;
  211.     }
  212.     public function setTokenRegistration(?string $tokenRegistration): static
  213.     {
  214.         $this->tokenRegistration $tokenRegistration;
  215.         return $this;
  216.     }
  217.     public function getTokenRegistrationLifeTime(): ?\DateTimeInterface
  218.     {
  219.         return $this->tokenRegistrationLifeTime;
  220.     }
  221.     public function setTokenRegistrationLifeTime(\DateTimeInterface $tokenRegistrationLifeTime): static
  222.     {
  223.         $this->tokenRegistrationLifeTime $tokenRegistrationLifeTime;
  224.         return $this;
  225.     }
  226.     public function isIsVerified(): ?bool
  227.     {
  228.         return $this->isVerified;
  229.     }
  230.     public function setIsVerified(bool $isVerified): static
  231.     {
  232.         $this->isVerified $isVerified;
  233.         return $this;
  234.     }
  235.     public function __toString()
  236.     {
  237.         return $this->nom;
  238.     }
  239.     /**
  240.      * @return Collection<int, JobCard>
  241.      */
  242.     public function getJobcards(): Collection
  243.     {
  244.         return $this->jobcards;
  245.     }
  246.     public function addJobcard(JobCard $jobcard): static
  247.     {
  248.         if (!$this->jobcards->contains($jobcard)) {
  249.             $this->jobcards->add($jobcard);
  250.             $jobcard->setUser($this);
  251.         }
  252.         return $this;
  253.     }
  254.     public function removeJobcard(JobCard $jobcard): static
  255.     {
  256.         if ($this->jobcards->removeElement($jobcard)) {
  257.             // set the owning side to null (unless already changed)
  258.             if ($jobcard->getUser() === $this) {
  259.                 $jobcard->setUser(null);
  260.             }
  261.         }
  262.         return $this;
  263.     }
  264.     public function getTypeClient(): ?string
  265.     {
  266.         return $this->typeClient;
  267.     }
  268.     public function setTypeClient(?string $typeClient): static
  269.     {
  270.         $this->typeClient $typeClient;
  271.         return $this;
  272.     }
  273.     public function getRccmFileName(): ?string
  274.     {
  275.         return $this->rccmFileName;
  276.     }
  277.     public function setRccmFileName(?string $rccmFileName): static
  278.     {
  279.         $this->rccmFileName $rccmFileName;
  280.         return $this;
  281.     }
  282.     public function getRccm(): ?string
  283.     {
  284.         return $this->rccm;
  285.     }
  286.     public function setRccm(?string $rccm): static
  287.     {
  288.         $this->rccm $rccm;
  289.         return $this;
  290.     }
  291.     /**
  292.      * @return Collection<int, Historique>
  293.      */
  294.     public function getHistoriques(): Collection
  295.     {
  296.         return $this->historiques;
  297.     }
  298.     public function addHistorique(Historique $historique): static
  299.     {
  300.         if (!$this->historiques->contains($historique)) {
  301.             $this->historiques->add($historique);
  302.             $historique->setUser($this);
  303.         }
  304.         return $this;
  305.     }
  306.     public function removeHistorique(Historique $historique): static
  307.     {
  308.         if ($this->historiques->removeElement($historique)) {
  309.             // set the owning side to null (unless already changed)
  310.             if ($historique->getUser() === $this) {
  311.                 $historique->setUser(null);
  312.             }
  313.         }
  314.         return $this;
  315.     }
  316.     /**
  317.      * @return Collection<int, Traveaux>
  318.      */
  319.     public function getTraveauxes(): Collection
  320.     {
  321.         return $this->traveauxes;
  322.     }
  323.     public function addTraveaux(Traveaux $traveaux): static
  324.     {
  325.         if (!$this->traveauxes->contains($traveaux)) {
  326.             $this->traveauxes->add($traveaux);
  327.             $traveaux->setResponsable($this);
  328.         }
  329.         return $this;
  330.     }
  331.     public function removeTraveaux(Traveaux $traveaux): static
  332.     {
  333.         if ($this->traveauxes->removeElement($traveaux)) {
  334.             // set the owning side to null (unless already changed)
  335.             if ($traveaux->getResponsable() === $this) {
  336.                 $traveaux->setResponsable(null);
  337.             }
  338.         }
  339.         return $this;
  340.     }
  341.     public function getProfil(): ?string
  342.     {
  343.         return $this->profil;
  344.     }
  345.     public function setProfil(?string $profil): static
  346.     {
  347.         $this->profil $profil;
  348.         return $this;
  349.     }
  350.     public function getNomCompletCommercial(): ?string
  351.     {
  352.         return $this->NomCompletCommercial;
  353.     }
  354.     public function setNomCompletCommercial(?string $NomCompletCommercial): static
  355.     {
  356.         $this->NomCompletCommercial $NomCompletCommercial;
  357.         return $this;
  358.     }
  359.     public function getNomEtreprise(): ?string
  360.     {
  361.         return $this->nomEtreprise;
  362.     }
  363.     public function setNomEtreprise(?string $nomEtreprise): static
  364.     {
  365.         $this->nomEtreprise $nomEtreprise;
  366.         return $this;
  367.     }
  368.     public function getStatusEntreprise(): ?string
  369.     {
  370.         return $this->statusEntreprise;
  371.     }
  372.     public function setStatusEntreprise(?string $statusEntreprise): static
  373.     {
  374.         $this->statusEntreprise $statusEntreprise;
  375.         return $this;
  376.     }
  377. }