src/Entity/User.php line 19

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\ORM\Mapping as ORM;
  7. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  8. use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
  9. use Symfony\Component\Security\Core\User\UserInterface;
  10. use Symfony\Component\Serializer\Annotation\Groups;
  11. /**
  12.  * @ORM\Entity(repositoryClass=UserRepository::class)
  13.  * @ORM\Table(name="`user`")
  14.  * @UniqueEntity(fields={"email"}, message="There is already an account with this email")
  15.  */
  16. class User implements UserInterfacePasswordAuthenticatedUserInterface
  17. {
  18.     /**
  19.      * @ORM\Id
  20.      * @ORM\GeneratedValue
  21.      * @ORM\Column(type="integer")
  22.      * @Groups({"message","post","post-group-session","conversation"})
  23.      */
  24.     private $id;
  25.     /**
  26.      * @ORM\Column(type="string", length=181)
  27.      */
  28.     private $email;
  29.     /**
  30.      * @ORM\Column(type="json")
  31.      */
  32.     private $roles = [];
  33.     /**
  34.      * @var string The hashed password
  35.      * @ORM\Column(type="string")
  36.      */
  37.     private $password;
  38.     /**
  39.      * @ORM\Column(type="boolean")
  40.      */
  41.     private $isVerified false;
  42.     /**
  43.      * @ORM\Column(type="integer", nullable=true)
  44.      */
  45.     private $idCustomer;
  46.     /**
  47.      * @ORM\Column(type="integer", nullable=true)
  48.      */
  49.     private $idUserProfil;
  50.     /**
  51.      * @ORM\Column(type="string", length=45, nullable=true)
  52.      */
  53.     private $job;
  54.     /**
  55.      * @ORM\Column(type="string", length=45, nullable=true)
  56.      */
  57.     private $service;
  58.     /**
  59.      * @ORM\Column(type="string", length=255, nullable=true)
  60.      */
  61.     private $schoolDegree1;
  62.     /**
  63.      * @ORM\Column(type="string", length=255, nullable=true)
  64.      */
  65.     private $schoolDegree2;
  66.     /**
  67.      * @ORM\Column(type="string", length=255, nullable=true)
  68.      */
  69.     private $userName;
  70.     /**
  71.      * @ORM\Column(type="string", length=255, nullable=true)
  72.      * @Groups({"message","post","post-group-session","conversation"})
  73.      */
  74.     private $lastName;
  75.     /**
  76.      * @ORM\Column(type="string", length=255, nullable=true)
  77.      * @Groups({"message","post","post-group-session","conversation"})
  78.      */
  79.     private $firstName;
  80.     /**
  81.      * @ORM\Column(type="boolean", nullable=true)
  82.      */
  83.     private $isActive;
  84.     /**
  85.      * @ORM\OneToMany(targetEntity=ParticipantConversation::class, mappedBy="user")
  86.      */
  87.     private $participants;
  88.     /**
  89.      * @ORM\OneToMany(targetEntity=Message::class, mappedBy="user")
  90.      */
  91.     private $messages;
  92.     /**
  93.      * @ORM\OneToMany(targetEntity=ForumTopic::class, mappedBy="user")
  94.      */
  95.     private $forumTopics;
  96.     /**
  97.      * @ORM\OneToMany(targetEntity=ForumPost::class, mappedBy="user")
  98.      */
  99.     private $forumPosts;
  100.     /**
  101.      * @ORM\ManyToMany(targetEntity=LMSFormation::class, mappedBy="user")
  102.      */
  103.     private $lMSFormations;
  104.     /**
  105.      * @ORM\OneToMany(targetEntity=LMSAnswerUser::class, mappedBy="user")
  106.      */
  107.     private $lMSAnswerUsers;
  108.     /**
  109.      * @ORM\ManyToMany(targetEntity=GroupSession::class, mappedBy="user")
  110.      */
  111.     private $groupSessions;
  112.     /**
  113.      * @ORM\OneToMany(targetEntity=GroupSessionMessage::class, mappedBy="user")
  114.      */
  115.     private $groupSessionMessages;
  116.     /**
  117.      * @ORM\ManyToMany(targetEntity=LMSContent::class, mappedBy="userProgression")
  118.      */
  119.     private $lMSContents;
  120.     /**
  121.      * @ORM\OneToMany(targetEntity=LMSAnswerSurveyUser::class, mappedBy="user")
  122.      */
  123.     private $lMSAnswerSurveyUsers;
  124.     /**
  125.      * @ORM\OneToMany(targetEntity=Notification::class, mappedBy="user")
  126.      */
  127.     private $notifications;
  128.     /**
  129.      * onSite / remote : définit le type de formation lors de l'inscription de l'étudiant et du paiemement. 
  130.      */
  131.     private $typeCourseSession;
  132.     /**
  133.      * @ORM\ManyToMany(targetEntity=LMSModule::class, mappedBy="user")
  134.      */
  135.     private $lMSModules;
  136.     /**
  137.      * @ORM\OneToMany(targetEntity=LMSFreeAnswerSurvey::class, mappedBy="user")
  138.      */
  139.     private $lMSFreeAnswerSurveys;
  140.     /**
  141.      * @ORM\ManyToMany(targetEntity=LMSSequence::class, inversedBy="users")
  142.      */
  143.     private $LMSSequences;
  144.     /**
  145.      * @ORM\Column(type="boolean", nullable=true)
  146.      */
  147.     private $isProfessional;
  148.     public function __construct()
  149.     {
  150.         $this->participants = new ArrayCollection();
  151.         $this->messages = new ArrayCollection();
  152.         $this->forumTopics = new ArrayCollection();
  153.         $this->forumPosts = new ArrayCollection();
  154.         $this->lMSFormations = new ArrayCollection();
  155.         $this->lMSAnswerUsers = new ArrayCollection();
  156.         $this->groupSessions = new ArrayCollection();
  157.         $this->groupSessionMessages = new ArrayCollection();
  158.         $this->lMSContents = new ArrayCollection();
  159.         $this->lMSAnswerSurveyUsers = new ArrayCollection();
  160.         $this->notifications = new ArrayCollection();
  161.         $this->typeCourseSession 0;
  162.         $this->lMSModules = new ArrayCollection();
  163.         $this->lMSFreeAnswerSurveys = new ArrayCollection();
  164.         $this->LMSSequences = new ArrayCollection();
  165.     }
  166.     public function getId(): ?int
  167.     {
  168.         return $this->id;
  169.     }
  170.     public function getEmail(): ?string
  171.     {
  172.         return $this->email;
  173.     }
  174.     public function setEmail(string $email): self
  175.     {
  176.         $this->email $email;
  177.         return $this;
  178.     }
  179.     /**
  180.      * A visual identifier that represents this user.
  181.      *
  182.      * @see UserInterface
  183.      */
  184.     public function getUserIdentifier(): string
  185.     {
  186.         return (string) $this->email;
  187.     }
  188.     /**
  189.      * @deprecated since Symfony 5.3, use getUserIdentifier instead
  190.      */
  191.     public function getUsername(): string
  192.     {
  193.         return (string) $this->userName;
  194.     }
  195.     /**
  196.      * @see UserInterface
  197.      */
  198.     public function getRoles(): array
  199.     {
  200.         $roles $this->roles;
  201.         // guarantee every user at least has ROLE_USER
  202.         $roles[] = 'ROLE_USER';
  203.         return array_unique($roles);
  204.     }
  205.     public function setRoles(array $roles): self
  206.     {
  207.         $this->roles $roles;
  208.         return $this;
  209.     }
  210.     /**
  211.      * @see PasswordAuthenticatedUserInterface
  212.      */
  213.     public function getPassword(): string
  214.     {
  215.         return $this->password;
  216.     }
  217.     public function setPassword(string $password): self
  218.     {
  219.         $this->password $password;
  220.         return $this;
  221.     }
  222.     /**
  223.      * Returning a salt is only needed, if you are not using a modern
  224.      * hashing algorithm (e.g. bcrypt or sodium) in your security.yaml.
  225.      *
  226.      * @see UserInterface
  227.      */
  228.     public function getSalt(): ?string
  229.     {
  230.         return null;
  231.     }
  232.     /**
  233.      * @see UserInterface
  234.      */
  235.     public function eraseCredentials()
  236.     {
  237.         // If you store any temporary, sensitive data on the user, clear it here
  238.         // $this->plainPassword = null;
  239.     }
  240.     public function isVerified(): bool
  241.     {
  242.         return $this->isVerified;
  243.     }
  244.     public function setIsVerified(bool $isVerified): self
  245.     {
  246.         $this->isVerified $isVerified;
  247.         return $this;
  248.     }
  249.     public function getIdCustomer(): ?int
  250.     {
  251.         return $this->idCustomer;
  252.     }
  253.     public function setIdCustomer(int $idCustomer): self
  254.     {
  255.         $this->idCustomer $idCustomer;
  256.         return $this;
  257.     }
  258.     public function getIdUserProfil(): ?int
  259.     {
  260.         return $this->idUserProfil;
  261.     }
  262.     public function setIdUserProfil(int $idUserProfil): self
  263.     {
  264.         $this->idUserProfil $idUserProfil;
  265.         return $this;
  266.     }
  267.     public function getJob(): ?string
  268.     {
  269.         return $this->job;
  270.     }
  271.     public function setJob(?string $job): self
  272.     {
  273.         $this->job $job;
  274.         return $this;
  275.     }
  276.     public function getService(): ?string
  277.     {
  278.         return $this->service;
  279.     }
  280.     public function setService(?string $service): self
  281.     {
  282.         $this->service $service;
  283.         return $this;
  284.     }
  285.     public function getSchoolDegree1(): ?string
  286.     {
  287.         return $this->schoolDegree1;
  288.     }
  289.     public function setSchoolDegree1(?string $schoolDegree1): self
  290.     {
  291.         $this->schoolDegree1 $schoolDegree1;
  292.         return $this;
  293.     }
  294.     public function getSchoolDegree2(): ?string
  295.     {
  296.         return $this->schoolDegree2;
  297.     }
  298.     public function setSchoolDegree2(?string $schoolDegree2): self
  299.     {
  300.         $this->schoolDegree2 $schoolDegree2;
  301.         return $this;
  302.     }
  303.     public function setUserName(?string $userName): self
  304.     {
  305.         $this->userName $userName;
  306.         return $this;
  307.     }
  308.     public function getLastName(): ?string
  309.     {
  310.         return $this->lastName;
  311.     }
  312.     public function setLastName(?string $lastName): self
  313.     {
  314.         $this->lastName $lastName;
  315.         return $this;
  316.     }
  317.     public function getFirstName(): ?string
  318.     {
  319.         return $this->firstName;
  320.     }
  321.     public function setFirstName(?string $firstName): self
  322.     {
  323.         $this->firstName $firstName;
  324.         return $this;
  325.     }
  326.     public function getIsActive(): ?bool
  327.     {
  328.         return $this->isActive;
  329.     }
  330.     public function setIsActive(?bool $isActive): self
  331.     {
  332.         $this->isActive $isActive;
  333.         return $this;
  334.     }
  335.     /**
  336.      * @return Collection<int, ParticipantConversation>
  337.      */
  338.     public function getParticipants(): Collection
  339.     {
  340.         return $this->participants;
  341.     }
  342.     public function addParticipant(ParticipantConversation $participant): self
  343.     {
  344.         if (!$this->participants->contains($participant)) {
  345.             $this->participants[] = $participant;
  346.             $participant->setUser($this);
  347.         }
  348.         return $this;
  349.     }
  350.     public function removeParticipant(ParticipantConversation $participant): self
  351.     {
  352.         if ($this->participants->removeElement($participant)) {
  353.             // set the owning side to null (unless already changed)
  354.             if ($participant->getUser() === $this) {
  355.                 $participant->setUser(null);
  356.             }
  357.         }
  358.         return $this;
  359.     }
  360.     /**
  361.      * @return Collection<int, Message>
  362.      */
  363.     public function getMessages(): Collection
  364.     {
  365.         return $this->messages;
  366.     }
  367.     public function addMessage(Message $message): self
  368.     {
  369.         if (!$this->messages->contains($message)) {
  370.             $this->messages[] = $message;
  371.             $message->setMessages($this);
  372.         }
  373.         return $this;
  374.     }
  375.     public function removeMessage(Message $message): self
  376.     {
  377.         if ($this->messages->removeElement($message)) {
  378.             // set the owning side to null (unless already changed)
  379.             if ($message->getMessages() === $this) {
  380.                 $message->setMessages(null);
  381.             }
  382.         }
  383.         return $this;
  384.     }
  385.     /**
  386.      * @return Collection<int, ForumTopic>
  387.      */
  388.     public function getForumTopics(): Collection
  389.     {
  390.         return $this->forumTopics;
  391.     }
  392.     public function addForumTopic(ForumTopic $forumTopic): self
  393.     {
  394.         if (!$this->forumTopics->contains($forumTopic)) {
  395.             $this->forumTopics[] = $forumTopic;
  396.             $forumTopic->setUser($this);
  397.         }
  398.         return $this;
  399.     }
  400.     public function removeForumTopic(ForumTopic $forumTopic): self
  401.     {
  402.         if ($this->forumTopics->removeElement($forumTopic)) {
  403.             // set the owning side to null (unless already changed)
  404.             if ($forumTopic->getUser() === $this) {
  405.                 $forumTopic->setUser(null);
  406.             }
  407.         }
  408.         return $this;
  409.     }
  410.     /**
  411.      * @return Collection<int, ForumPost>
  412.      */
  413.     public function getForumPosts(): Collection
  414.     {
  415.         return $this->forumPosts;
  416.     }
  417.     public function addForumPost(ForumPost $forumPost): self
  418.     {
  419.         if (!$this->forumPosts->contains($forumPost)) {
  420.             $this->forumPosts[] = $forumPost;
  421.             $forumPost->setUser($this);
  422.         }
  423.         return $this;
  424.     }
  425.     public function removeForumPost(ForumPost $forumPost): self
  426.     {
  427.         if ($this->forumPosts->removeElement($forumPost)) {
  428.             // set the owning side to null (unless already changed)
  429.             if ($forumPost->getUser() === $this) {
  430.                 $forumPost->setUser(null);
  431.             }
  432.         }
  433.         return $this;
  434.     }
  435.     /**
  436.      * @return Collection<int, LMSFormation>
  437.      */
  438.     public function getLMSFormations(): Collection
  439.     {
  440.         return $this->lMSFormations;
  441.     }
  442.     public function addLMSFormation(LMSFormation $lMSFormation): self
  443.     {
  444.         if (!$this->lMSFormations->contains($lMSFormation)) {
  445.             $this->lMSFormations[] = $lMSFormation;
  446.             $lMSFormation->addUser($this);
  447.         }
  448.         return $this;
  449.     }
  450.     public function removeLMSFormation(LMSFormation $lMSFormation): self
  451.     {
  452.         if ($this->lMSFormations->removeElement($lMSFormation)) {
  453.             $lMSFormation->removeUser($this);
  454.         }
  455.         return $this;
  456.     }
  457.     /**
  458.      * @return Collection<int, LMSAnswerUser>
  459.      */
  460.     public function getLMSAnswerUsers(): Collection
  461.     {
  462.         return $this->lMSAnswerUsers;
  463.     }
  464.     public function addLMSAnswerUser(LMSAnswerUser $lMSAnswerUser): self
  465.     {
  466.         if (!$this->lMSAnswerUsers->contains($lMSAnswerUser)) {
  467.             $this->lMSAnswerUsers[] = $lMSAnswerUser;
  468.             $lMSAnswerUser->setUser($this);
  469.         }
  470.         return $this;
  471.     }
  472.     public function removeLMSAnswerUser(LMSAnswerUser $lMSAnswerUser): self
  473.     {
  474.         if ($this->lMSAnswerUsers->removeElement($lMSAnswerUser)) {
  475.             // set the owning side to null (unless already changed)
  476.             if ($lMSAnswerUser->getUser() === $this) {
  477.                 $lMSAnswerUser->setUser(null);
  478.             }
  479.         }
  480.         return $this;
  481.     }
  482.     /**
  483.      * @return Collection<int, GroupSession>
  484.      */
  485.     public function getGroupSessions(): Collection
  486.     {
  487.         return $this->groupSessions;
  488.     }
  489.     public function addGroupSession(GroupSession $groupSession): self
  490.     {
  491.         if (!$this->groupSessions->contains($groupSession)) {
  492.             $this->groupSessions[] = $groupSession;
  493.             $groupSession->addUser($this);
  494.         }
  495.         return $this;
  496.     }
  497.     public function removeGroupSession(GroupSession $groupSession): self
  498.     {
  499.         if ($this->groupSessions->removeElement($groupSession)) {
  500.             $groupSession->removeUser($this);
  501.         }
  502.         return $this;
  503.     }
  504.     /**
  505.      * @return Collection<int, GroupSessionMessage>
  506.      */
  507.     public function getGroupSessionMessages(): Collection
  508.     {
  509.         return $this->groupSessionMessages;
  510.     }
  511.     public function addGroupSessionMessage(GroupSessionMessage $groupSessionMessage): self
  512.     {
  513.         if (!$this->groupSessionMessages->contains($groupSessionMessage)) {
  514.             $this->groupSessionMessages[] = $groupSessionMessage;
  515.             $groupSessionMessage->setUser($this);
  516.         }
  517.         return $this;
  518.     }
  519.     public function removeGroupSessionMessage(GroupSessionMessage $groupSessionMessage): self
  520.     {
  521.         if ($this->groupSessionMessages->removeElement($groupSessionMessage)) {
  522.             // set the owning side to null (unless already changed)
  523.             if ($groupSessionMessage->getUser() === $this) {
  524.                 $groupSessionMessage->setUser(null);
  525.             }
  526.         }
  527.         return $this;
  528.     }
  529.     /**
  530.      * @return Collection<int, LMSContent>
  531.      */
  532.     public function getLMSContents(): Collection
  533.     {
  534.         return $this->lMSContents;
  535.     }
  536.     public function addLMSContent(LMSContent $lMSContent): self
  537.     {
  538.         if (!$this->lMSContents->contains($lMSContent)) {
  539.             $this->lMSContents[] = $lMSContent;
  540.             $lMSContent->addUserProgression($this);
  541.         }
  542.         return $this;
  543.     }
  544.     public function removeLMSContent(LMSContent $lMSContent): self
  545.     {
  546.         if ($this->lMSContents->removeElement($lMSContent)) {
  547.             $lMSContent->removeUserProgression($this);
  548.         }
  549.         return $this;
  550.     }
  551.     /**
  552.      * @return Collection<int, LMSAnswerSurveyUser>
  553.      */
  554.     public function getLMSAnswerSurveyUsers(): Collection
  555.     {
  556.         return $this->lMSAnswerSurveyUsers;
  557.     }
  558.     public function addLMSAnswerSurveyUser(LMSAnswerSurveyUser $lMSAnswerSurveyUser): self
  559.     {
  560.         if (!$this->lMSAnswerSurveyUsers->contains($lMSAnswerSurveyUser)) {
  561.             $this->lMSAnswerSurveyUsers[] = $lMSAnswerSurveyUser;
  562.             $lMSAnswerSurveyUser->setUser($this);
  563.         }
  564.         return $this;
  565.     }
  566.     public function removeLMSAnswerSurveyUser(LMSAnswerSurveyUser $lMSAnswerSurveyUser): self
  567.     {
  568.         if ($this->lMSAnswerSurveyUsers->removeElement($lMSAnswerSurveyUser)) {
  569.             // set the owning side to null (unless already changed)
  570.             if ($lMSAnswerSurveyUser->getUser() === $this) {
  571.                 $lMSAnswerSurveyUser->setUser(null);
  572.             }
  573.         }
  574.         return $this;
  575.     }
  576.     /**
  577.      * @return Collection<int, Notification>
  578.      */
  579.     public function getNotifications(): Collection
  580.     {
  581.         return $this->notifications;
  582.     }
  583.     public function addNotification(Notification $notification): self
  584.     {
  585.         if (!$this->notifications->contains($notification)) {
  586.             $this->notifications[] = $notification;
  587.             $notification->setUser($this);
  588.         }
  589.         return $this;
  590.     }
  591.     public function removeNotification(Notification $notification): self
  592.     {
  593.         if ($this->notifications->removeElement($notification)) {
  594.             // set the owning side to null (unless already changed)
  595.             if ($notification->getUser() === $this) {
  596.                 $notification->setUser(null);
  597.             }
  598.         }
  599.         return $this;
  600.     }
  601.     /**
  602.      * Get onSite / remote : définit le type de formation lors de l'inscription de l'étudiant et du paiemement.
  603.      */ 
  604.     public function getTypeCourseSession()
  605.     {
  606.         return $this->typeCourseSession;
  607.     }
  608.     /**
  609.      * Set onSite / remote : définit le type de formation lors de l'inscription de l'étudiant et du paiemement.
  610.      *
  611.      * @return  self
  612.      */ 
  613.     public function setTypeCourseSession($typeCourseSession)
  614.     {
  615.         $this->typeCourseSession $typeCourseSession;
  616.         return $this;
  617.     }
  618.     /**
  619.      * @return Collection<int, LMSModule>
  620.      */
  621.     public function getLMSModules(): Collection
  622.     {
  623.         return $this->lMSModules;
  624.     }
  625.     public function addLMSModule(LMSModule $lMSModule): self
  626.     {
  627.         if (!$this->lMSModules->contains($lMSModule)) {
  628.             $this->lMSModules[] = $lMSModule;
  629.             $lMSModule->addUser($this);
  630.         }
  631.         return $this;
  632.     }
  633.     public function removeLMSModule(LMSModule $lMSModule): self
  634.     {
  635.         if ($this->lMSModules->removeElement($lMSModule)) {
  636.             $lMSModule->removeUser($this);
  637.         }
  638.         return $this;
  639.     }
  640.     /**
  641.      * @return Collection<int, LMSFreeAnswerSurvey>
  642.      */
  643.     public function getLMSFreeAnswerSurveys(): Collection
  644.     {
  645.         return $this->lMSFreeAnswerSurveys;
  646.     }
  647.     public function addLMSFreeAnswerSurvey(LMSFreeAnswerSurvey $lMSFreeAnswerSurvey): self
  648.     {
  649.         if (!$this->lMSFreeAnswerSurveys->contains($lMSFreeAnswerSurvey)) {
  650.             $this->lMSFreeAnswerSurveys[] = $lMSFreeAnswerSurvey;
  651.             $lMSFreeAnswerSurvey->setUser($this);
  652.         }
  653.         return $this;
  654.     }
  655.     public function removeLMSFreeAnswerSurvey(LMSFreeAnswerSurvey $lMSFreeAnswerSurvey): self
  656.     {
  657.         if ($this->lMSFreeAnswerSurveys->removeElement($lMSFreeAnswerSurvey)) {
  658.             // set the owning side to null (unless already changed)
  659.             if ($lMSFreeAnswerSurvey->getUser() === $this) {
  660.                 $lMSFreeAnswerSurvey->setUser(null);
  661.             }
  662.         }
  663.         return $this;
  664.     }
  665.     /**
  666.      * @return Collection<int, LMSSequence>
  667.      */
  668.     public function getLMSSequences(): Collection
  669.     {
  670.         return $this->LMSSequences;
  671.     }
  672.     public function addLMSSequence(LMSSequence $lMSSequence): self
  673.     {
  674.         if (!$this->LMSSequences->contains($lMSSequence)) {
  675.             $this->LMSSequences[] = $lMSSequence;
  676.         }
  677.         return $this;
  678.     }
  679.     public function removeLMSSequence(LMSSequence $lMSSequence): self
  680.     {
  681.         $this->LMSSequences->removeElement($lMSSequence);
  682.         return $this;
  683.     }
  684.     public function getIsProfessional(): ?bool
  685.     {
  686.         return $this->isProfessional;
  687.     }
  688.     public function setIsProfessional(?bool $isProfessional): self
  689.     {
  690.         $this->isProfessional $isProfessional;
  691.         return $this;
  692.     }
  693. }