src/Entity/User.php line 31

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\DBAL\Types\Types;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use ApiPlatform\Core\Annotation\ApiResource;
  9. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  10. use Symfony\Component\HttpFoundation\File\File;
  11. use Symfony\Component\Serializer\Annotation\Groups;
  12. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  13. use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
  14. use Symfony\Component\Security\Core\User\UserInterface;
  15. use App\Controller\ResetRandomPasswordController;
  16. use App\Controller\ResetPasswordController;
  17. use App\Controller\ResetPasswordRequestController;
  18. use App\Controller\UpdateUserCvController;
  19. use App\Controller\UpdateUserPhotoController;
  20. use Symfony\Component\Validator\Constraints as Assert;
  21. use App\Billing\Model\BillablePartyInterface;
  22. #[ORM\Entity(repositoryClassUserRepository::class)]
  23. #[ORM\Table(name'`user`')]
  24. #[Vich\Uploadable]
  25. class User implements UserInterfacePasswordAuthenticatedUserInterfaceBillablePartyInterface
  26. {
  27.     #[ORM\Id]
  28.     #[ORM\GeneratedValue]
  29.     #[ORM\Column]
  30.     #[Groups(['read:collection:user''read:item:user'])]
  31.     private ?int $id null;
  32.     #[ORM\Column(length180uniquetrue)]
  33.     #[Assert\NotBlank(message"Le champ ne peut pas être vide.")]
  34.     #[Groups(['write:collection:resetpassword''read:collection:user''write:collection:user''read:item:user''put:item:user'])]
  35.     private ?string $username null;
  36.     #[ORM\Column]
  37.     #[Groups(['read:collection:user''write:collection:user''read:item:user''put:item:user'])]
  38.     private array $roles = [];
  39.     /**
  40.      * @var string The hashed password
  41.      */
  42.     #[ORM\Column]
  43.     #[Groups(['read:collection:user''write:collection:user''read:item:user''put:item:user'])]
  44.     private ?string $password null;
  45.     #[ORM\Column(length255nullabletrue)]
  46.     private ?string $resetPasswordToken null;
  47.     #[ORM\Column(length255nullabletrue)]
  48.     #[Groups(['read:collection:user''write:collection:user''read:item:user''put:item:user'])]
  49.     private ?string $civilite null;
  50.     #[ORM\Column(length255nullabletrue)]
  51.     #[Groups(['read:collection:user''write:collection:user''read:item:user''put:item:user'])]
  52.     private ?string $cin null;
  53.     #[ORM\Column(length255nullabletrue)]
  54.     #[Assert\NotBlank(message"Le champ ne peut pas être vide.")]
  55.     #[Groups(['read:collection:user''write:collection:user''read:item:user''put:item:user'])]
  56.     private ?string $nom null;
  57.     #[ORM\Column(length255nullabletrue)]
  58.     #[Assert\NotBlank(message"Le champ ne peut pas être vide.")]
  59.     #[Groups(['read:collection:user''write:collection:user''read:item:user''put:item:user'])]
  60.     private ?string $prenom null;
  61.     #[ORM\Column(typeTypes::DATETIME_MUTABLEnullabletrue)]
  62.     #[Groups(['read:collection:user''write:collection:user''read:item:user''put:item:user'])]
  63.     private ?\DateTimeInterface $dateNaissance null;
  64.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  65.     #[Groups(['read:collection:user''write:collection:user''read:item:user''put:item:user'])]
  66.     private ?string $adresse null;
  67.     #[ORM\Column(nullabletrue)]
  68.     #[Groups(['read:collection:user''write:collection:user''read:item:user''put:item:user'])]
  69.     private ?int $codePostal null;
  70.     #[ORM\Column(length255nullabletrue)]
  71.     #[Groups(['read:collection:user''write:collection:user''read:item:user''put:item:user'])]
  72.     private ?string $ville null;
  73.     #[ORM\Column(length255nullabletrue)]
  74.     #[Groups(['read:collection:user''write:collection:user''read:item:user''put:item:user'])]
  75.     private ?string $tel null;
  76.     #[ORM\Column(length255nullabletrue)]
  77.     #[Groups(['read:collection:user''write:collection:user''read:item:user''put:item:user'])]
  78.     private ?string $fax null;
  79.     #[ORM\Column(nullabletrue)]
  80.     #[Groups(['read:collection:user''write:collection:user''read:item:user''put:item:user'])]
  81.     private ?int $etatActivation null;
  82.     #[ORM\Column(length255nullabletrue)]
  83.     #[Groups(['read:collection:user''write:collection:user''read:item:user''put:item:user'])]
  84.     private ?string $niveau null;
  85.     #[ORM\Column(length255nullabletrue)]
  86.     #[Groups(['read:collection:user''write:collection:user''read:item:user''put:item:user'])]
  87.     private ?string $specialite null;
  88.     #[ORM\Column(length255nullabletrue)]
  89.     #[Groups(['read:collection:user''write:collection:user''read:item:user''put:item:user'])]
  90.     private ?string $experience null;
  91.     #[ORM\Column(length255nullabletrue)]
  92.     #[Groups(['read:collection:user''write:collection:user''read:item:user''put:item:user'])]
  93.     private ?string $type null;
  94.     #[ORM\Column(length255nullabletrue)]
  95.     #[Groups(['read:collection:user''write:collection:user''read:item:user''put:item:user'])]
  96.     private ?string $diplome null;
  97.     #[ORM\Column(length255nullabletrue)]
  98.     #[Groups(['read:collection:user''write:collection:user''read:item:user''put:item:user'])]
  99.     private ?string $institution null;
  100.     #[ORM\Column(length255nullabletrue)]
  101.     #[Groups(['read:collection:user''write:collection:user''read:item:user''put:item:user'])]
  102.     private ?string $poste null;
  103.     #[ORM\Column(length255nullabletrue)]
  104.     #[Groups(['read:collection:user''write:collection:user''read:item:user''put:item:user'])]
  105.     private ?string $nationnalite null;
  106.     #[ORM\OneToMany(mappedBy'formateur'targetEntityEngagement::class)]
  107.     private Collection $engagements;
  108.     #[ORM\ManyToOne(inversedBy'users')]
  109.     private ?Organization $organization null;
  110.     #[ORM\OneToMany(mappedBy'candidat'targetEntityInscription::class)]
  111.     private Collection $inscriptions;
  112.     #[ORM\Column(length255nullabletrue)]
  113.     private ?string $cv null;
  114.     #[Vich\UploadableField(mapping'usercv'fileNameProperty'cv')]
  115.     public $cvFile;
  116.     #[ORM\Column(length255nullabletrue)]
  117.     private ?string $photoDeProfil null;
  118.     #[Vich\UploadableField(mapping'userphoto'fileNameProperty'photoDeProfil')]
  119.     public ?File $photoDeProfilFile null;
  120.     #[ORM\Column(typeTypes::DATETIME_MUTABLEnullabletrue)]
  121.     private ?\DateTimeInterface $updatedAt null;
  122.     #[ORM\OneToMany(mappedBy'user'targetEntityCertificat::class)]
  123.     private Collection $certificats;
  124.     #[ORM\Column(length180uniquetrue)]
  125.     private ?string $email null;
  126.     #[ORM\OneToMany(mappedBy'user'targetEntityServiceUsage::class)]
  127.     private Collection $serviceUsages;
  128.     public function __construct()
  129.     {
  130.         $this->engagements = new ArrayCollection();
  131.         $this->inscriptions = new ArrayCollection();
  132.         $this->certificats = new ArrayCollection();
  133.         $this->serviceUsages = new ArrayCollection();
  134.     }
  135.     public function __toString()
  136.     {
  137.         return $this->email;
  138.     }
  139.     public function getId(): ?int
  140.     {
  141.         return $this->id;
  142.     }
  143.     public function setCvFile(File $cvFile null)
  144.     {
  145.         $this->cvFile $cvFile;
  146.         if (null !== $cvFile) {
  147.             $this->updatedAt = new \Datetime();
  148.         }
  149.     }
  150.     public function getCvFile()
  151.     {
  152.         return $this->cvFile;
  153.     }
  154.     public function setPhotoDeProfilFile(File $photoDeProfilFile null)
  155.     {
  156.         $this->photoDeProfilFile $photoDeProfilFile;
  157.         if (null !== $photoDeProfilFile) {
  158.             $this->updatedAt = new \Datetime();
  159.         }
  160.     }
  161.     public function getPhotoDeProfilFile()
  162.     {
  163.         return $this->photoDeProfilFile;
  164.     }
  165.     /**
  166.      * @deprecated since Symfony 5.3, use getUserIdentifier instead
  167.      */
  168.     public function getUsername(): string
  169.     {
  170.         return (string) $this->email;
  171.     }
  172.     public function setUsername(string $username): self
  173.     {
  174.         $this->email $username;
  175.         $this->username $username;
  176.         return $this;
  177.     }
  178.     /**
  179.      * A visual identifier that represents this user.
  180.      *
  181.      * @see UserInterface
  182.      */
  183.     public function getUserIdentifier(): string
  184.     {
  185.         return (string) $this->email;
  186.     }
  187.     /**
  188.      * @see UserInterface
  189.      */
  190.     public function getRoles(): array
  191.     {
  192.         $roles $this->roles;
  193.         // guarantee every user at least has ROLE_USER
  194.         $roles[] = 'ROLE_USER';
  195.         return array_unique($roles);
  196.     }
  197.     public function setRoles(array $roles): self
  198.     {
  199.         $this->roles $roles;
  200.         return $this;
  201.     }
  202.     /**
  203.      * @see PasswordAuthenticatedUserInterface
  204.      */
  205.     public function getPassword(): string
  206.     {
  207.         return $this->password;
  208.     }
  209.     public function setPassword(string $password): self
  210.     {
  211.         $this->password $password;
  212.         return $this;
  213.     }
  214.     /**
  215.      * Returning a salt is only needed, if you are not using a modern
  216.      * hashing algorithm (e.g. bcrypt or sodium) in your security.yaml.
  217.      *
  218.      * @see UserInterface
  219.      */
  220.     public function getSalt(): ?string
  221.     {
  222.         return null;
  223.     }
  224.     /**
  225.      * @see UserInterface
  226.      */
  227.     public function eraseCredentials()
  228.     {
  229.         // If you store any temporary, sensitive data on the user, clear it here
  230.         // $this->plainPassword = null;
  231.     }
  232.     /**
  233.      * Get the value of plainPassword
  234.      */
  235.     public function getPlainPassword()
  236.     {
  237.         return $this->plainPassword;
  238.     }
  239.     /**
  240.      * Set the value of plainPassword
  241.      *
  242.      * @return  self
  243.      */
  244.     public function setPlainPassword($plainPassword)
  245.     {
  246.         $this->plainPassword $plainPassword;
  247.         return $this;
  248.     }
  249.     public function getResetPasswordToken(): ?string
  250.     {
  251.         return $this->resetPasswordToken;
  252.     }
  253.     public function setResetPasswordToken(?string $resetPasswordToken): self
  254.     {
  255.         $this->resetPasswordToken $resetPasswordToken;
  256.         return $this;
  257.     }
  258.     public function getCivilite(): ?string
  259.     {
  260.         return $this->civilite;
  261.     }
  262.     public function setCivilite(?string $civilite): self
  263.     {
  264.         $this->civilite $civilite;
  265.         return $this;
  266.     }
  267.     public function getNom(): ?string
  268.     {
  269.         return $this->nom;
  270.     }
  271.     public function setNom(?string $nom): self
  272.     {
  273.         $this->nom $nom;
  274.         return $this;
  275.     }
  276.     public function getPrenom(): ?string
  277.     {
  278.         return $this->prenom;
  279.     }
  280.     public function setPrenom(?string $prenom): self
  281.     {
  282.         $this->prenom $prenom;
  283.         return $this;
  284.     }
  285.     public function getDateNaissance(): ?\DateTimeInterface
  286.     {
  287.         return $this->dateNaissance;
  288.     }
  289.     public function setDateNaissance(?\DateTimeInterface $dateNaissance): self
  290.     {
  291.         $this->dateNaissance $dateNaissance;
  292.         return $this;
  293.     }
  294.     public function getAdresse(): ?string
  295.     {
  296.         return $this->adresse;
  297.     }
  298.     public function setAdresse(?string $adresse): self
  299.     {
  300.         $this->adresse $adresse;
  301.         return $this;
  302.     }
  303.     public function getCodePostal(): ?int
  304.     {
  305.         return $this->codePostal;
  306.     }
  307.     public function setCodePostal(?int $codePostal): self
  308.     {
  309.         $this->codePostal $codePostal;
  310.         return $this;
  311.     }
  312.     public function getVille(): ?string
  313.     {
  314.         return $this->ville;
  315.     }
  316.     public function setVille(?string $ville): self
  317.     {
  318.         $this->ville $ville;
  319.         return $this;
  320.     }
  321.     public function getTel(): ?string
  322.     {
  323.         return $this->tel;
  324.     }
  325.     public function setTel(?string $tel): self
  326.     {
  327.         $this->tel $tel;
  328.         return $this;
  329.     }
  330.     public function getFax(): ?string
  331.     {
  332.         return $this->fax;
  333.     }
  334.     public function setFax(?string $fax): self
  335.     {
  336.         $this->fax $fax;
  337.         return $this;
  338.     }
  339.     public function getEtatActivation(): ?int
  340.     {
  341.         return $this->etatActivation;
  342.     }
  343.     public function setEtatActivation(?int $etatActivation): self
  344.     {
  345.         $this->etatActivation $etatActivation;
  346.         return $this;
  347.     }
  348.     public function getNiveau(): ?string
  349.     {
  350.         return $this->niveau;
  351.     }
  352.     public function setNiveau(?string $niveau): self
  353.     {
  354.         $this->niveau $niveau;
  355.         return $this;
  356.     }
  357.     public function getSpecialite(): ?string
  358.     {
  359.         return $this->specialite;
  360.     }
  361.     public function setSpecialite(?string $specialite): self
  362.     {
  363.         $this->specialite $specialite;
  364.         return $this;
  365.     }
  366.     public function getExperience(): ?string
  367.     {
  368.         return $this->experience;
  369.     }
  370.     public function setExperience(?string $experience): self
  371.     {
  372.         $this->experience $experience;
  373.         return $this;
  374.     }
  375.     public function getType(): ?string
  376.     {
  377.         return $this->type;
  378.     }
  379.     public function setType(?string $type): self
  380.     {
  381.         $this->type $type;
  382.         return $this;
  383.     }
  384.     public function getDiplome(): ?string
  385.     {
  386.         return $this->diplome;
  387.     }
  388.     public function setDiplome(?string $diplome): self
  389.     {
  390.         $this->diplome $diplome;
  391.         return $this;
  392.     }
  393.     public function getInstitution(): ?string
  394.     {
  395.         return $this->institution;
  396.     }
  397.     public function setInstitution(?string $institution): self
  398.     {
  399.         $this->institution $institution;
  400.         return $this;
  401.     }
  402.     public function getPoste(): ?string
  403.     {
  404.         return $this->poste;
  405.     }
  406.     public function setPoste(?string $poste): self
  407.     {
  408.         $this->poste $poste;
  409.         return $this;
  410.     }
  411.     public function getNationnalite(): ?string
  412.     {
  413.         return $this->nationnalite;
  414.     }
  415.     public function setNationnalite(?string $nationnalite): self
  416.     {
  417.         $this->nationnalite $nationnalite;
  418.         return $this;
  419.     }
  420.     /**
  421.      * @return Collection<int, Engagement>
  422.      */
  423.     public function getEngagements(): Collection
  424.     {
  425.         return $this->engagements;
  426.     }
  427.     public function addEngagement(Engagement $engagement): self
  428.     {
  429.         if (!$this->engagements->contains($engagement)) {
  430.             $this->engagements->add($engagement);
  431.             $engagement->setFormateur($this);
  432.         }
  433.         return $this;
  434.     }
  435.     public function removeEngagement(Engagement $engagement): self
  436.     {
  437.         if ($this->engagements->removeElement($engagement)) {
  438.             // set the owning side to null (unless already changed)
  439.             if ($engagement->getFormateur() === $this) {
  440.                 $engagement->setFormateur(null);
  441.             }
  442.         }
  443.         return $this;
  444.     }
  445.     /**
  446.      * @return Collection<int, Inscription>
  447.      */
  448.     public function getInscriptions(): Collection
  449.     {
  450.         return $this->inscriptions;
  451.     }
  452.     public function addInscription(Inscription $inscription): self
  453.     {
  454.         if (!$this->inscriptions->contains($inscription)) {
  455.             $this->inscriptions->add($inscription);
  456.             $inscription->setCandidat($this);
  457.         }
  458.         return $this;
  459.     }
  460.     public function removeInscription(Inscription $inscription): self
  461.     {
  462.         if ($this->inscriptions->removeElement($inscription)) {
  463.             // set the owning side to null (unless already changed)
  464.             if ($inscription->getCandidat() === $this) {
  465.                 $inscription->setCandidat(null);
  466.             }
  467.         }
  468.         return $this;
  469.     }
  470.     public function getCv(): ?string
  471.     {
  472.         return $this->cv;
  473.     }
  474.     public function setCv(?string $cv): self
  475.     {
  476.         $this->cv $cv;
  477.         return $this;
  478.     }
  479.     public function getPhotoDeProfil(): ?string
  480.     {
  481.         return $this->photoDeProfil;
  482.     }
  483.     public function setPhotoDeProfil(?string $photoDeProfil): self
  484.     {
  485.         $this->photoDeProfil $photoDeProfil;
  486.         return $this;
  487.     }
  488.     public function getUpdatedAt(): ?\DateTimeInterface
  489.     {
  490.         return $this->updatedAt;
  491.     }
  492.     public function setUpdatedAt(?\DateTimeInterface $updatedAt): self
  493.     {
  494.         $this->updatedAt $updatedAt;
  495.         return $this;
  496.     }
  497.     /**
  498.      * @return Collection<int, Certificat>
  499.      */
  500.     public function getCertificats(): Collection
  501.     {
  502.         return $this->certificats;
  503.     }
  504.     public function addCertificat(Certificat $certificat): self
  505.     {
  506.         if (!$this->certificats->contains($certificat)) {
  507.             $this->certificats->add($certificat);
  508.             $certificat->setUser($this);
  509.         }
  510.         return $this;
  511.     }
  512.     public function removeCertificat(Certificat $certificat): self
  513.     {
  514.         if ($this->certificats->removeElement($certificat)) {
  515.             // set the owning side to null (unless already changed)
  516.             if ($certificat->getUser() === $this) {
  517.                 $certificat->setUser(null);
  518.             }
  519.         }
  520.         return $this;
  521.     }
  522.     public function getEmail(): ?string
  523.     {
  524.         return $this->email;
  525.     }
  526.     public function setEmail(?string $email): self
  527.     {
  528.         $this->email $email;
  529.         $this->username $email;
  530.         return $this;
  531.     }
  532.     public function getCin(): ?string
  533.     {
  534.         return $this->cin;
  535.     }
  536.     public function setCin(?string $cin): static
  537.     {
  538.         $this->cin $cin;
  539.         return $this;
  540.     }
  541.     public function getOrganization(): ?Organization
  542.     {
  543.         return $this->organization;
  544.     }
  545.     public function setOrganization(?Organization $organization): static
  546.     {
  547.         $this->organization $organization;
  548.         return $this;
  549.     }
  550.     // BillablePartyInterface implementation
  551.     public function getBillingName(): string
  552.     {
  553.         return $this->prenom ' ' $this->nom;
  554.     }
  555.     public function getBillingAddress(): ?string
  556.     {
  557.         $address $this->adresse;
  558.         if ($this->ville) {
  559.             $address .= ', ' $this->ville;
  560.         }
  561.         if ($this->codePostal) {
  562.             $address .= ' ' $this->codePostal;
  563.         }
  564.         return $address;
  565.     }
  566.     public function getTaxId(): ?string
  567.     {
  568.         // For individual users, this might be null unless they are independent contractors
  569.         // We could use CIN or matriculeFiscaleOrganisation if relevant, but let's keep it simple for now
  570.         return null;
  571.     }
  572.     public function getBillingEmail(): ?string
  573.     {
  574.         return $this->email;
  575.     }
  576. }