src/Entity/User.php line 17

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. /**
  11.  * @ORM\Entity(repositoryClass=UserRepository::class)
  12.  * @UniqueEntity(fields={"email"}, message="Cette adresse email est déjà utilisée.")
  13.  */
  14. class User implements UserInterfacePasswordAuthenticatedUserInterface
  15. {
  16.     /**
  17.      * @ORM\Id
  18.      * @ORM\GeneratedValue
  19.      * @ORM\Column(type="integer")
  20.      */
  21.     private $id;
  22.     /**
  23.      * @ORM\Column(type="string", length=180, unique=true)
  24.      */
  25.     private $email;
  26.     /**
  27.      * @ORM\Column(type="json")
  28.      */
  29.     private $roles = [];
  30.     /**
  31.      * @var string The hashed password
  32.      * @ORM\Column(type="string")
  33.      */
  34.     private $password;
  35.     /**
  36.      * @ORM\Column(type="boolean")
  37.      */
  38.     private $isVerified false;
  39.     /**
  40.      * @ORM\Column(type="string", length=255)
  41.      */
  42.     private $salt;
  43.     /**
  44.      * @ORM\Column(type="string", length=100, nullable=true)
  45.      */
  46.     private $firstName;
  47.     /**
  48.      * @ORM\Column(type="string", length=100, nullable=true)
  49.      */
  50.     private $lastName;
  51.     /**
  52.      * @ORM\Column(type="boolean")
  53.      */
  54.     private $isActive;
  55.     /**
  56.      * @ORM\Column(type="datetime")
  57.      */
  58.     private $createdAt;
  59.     /**
  60.      * @ORM\Column(type="datetime")
  61.      */
  62.     private $modifiedAt;
  63.     /**
  64.      * @ORM\Column(type="datetime", nullable=true)
  65.      */
  66.     private $recentlyLoggedAt;
  67.     /**
  68.      * @ORM\Column(type="datetime", nullable=true)
  69.      */
  70.     private $disabledAt;
  71.     /**
  72.      * @ORM\OneToMany(targetEntity=FlashUserWorkshop::class, mappedBy="user")
  73.      */
  74.     private $flashUserWorkshops;
  75.     /**
  76.      * @ORM\Column(type="string", length=255, nullable=true)
  77.      */
  78.     private $jobTitle;
  79.     /**
  80.      * @ORM\ManyToMany(targetEntity=Job::class, inversedBy="users")
  81.      */
  82.     private $job;
  83.     /**
  84.      * @ORM\ManyToMany(targetEntity=Subject::class, inversedBy="users")
  85.      */
  86.     private $subject;
  87.     /**
  88.      * @ORM\ManyToOne(targetEntity=Location::class, inversedBy="users")
  89.      * @ORM\JoinColumn(nullable=true)
  90.      */
  91.     private $location;
  92.     /**
  93.      * @ORM\ManyToOne(targetEntity=SubLocation::class, inversedBy="users")
  94.      * @ORM\JoinColumn(nullable=true)
  95.      */
  96.     private $subLocation;
  97.     /**
  98.      * @ORM\ManyToOne(targetEntity=Client::class, inversedBy="users")
  99.      * @ORM\JoinColumn(nullable=false)
  100.      */
  101.     private $client;
  102.     /**
  103.      * @ORM\OneToMany(targetEntity=UserProduct::class, mappedBy="user")
  104.      */
  105.     private $userProducts;
  106.     /**
  107.      * @ORM\OneToMany(targetEntity=DefiAnswerUser::class, mappedBy="user")
  108.      */
  109.     private $defiAnswerUsers;
  110.     /**
  111.      * @ORM\Column(type="string", length=255, nullable=true)
  112.      */
  113.     private $icon;
  114.     /**
  115.      * @ORM\OneToMany(targetEntity=Contact::class, mappedBy="user")
  116.      */
  117.     private $contacts;
  118.     /**
  119.      * @ORM\ManyToOne(targetEntity=Avatar::class, inversedBy="users")
  120.      */
  121.     private $avatar;
  122.     /**
  123.      * @ORM\Column(type="string", length=30, nullable=true)
  124.      */
  125.     private $age;
  126.     /**
  127.      * @ORM\OneToMany(targetEntity=DiagAnswerUser::class, mappedBy="user")
  128.      */
  129.     private $diagAnswerUsers;
  130.     public function __construct()
  131.     {
  132.         $this->flashUserWorkshops = new ArrayCollection();
  133.         $this->job = new ArrayCollection();
  134.         $this->subject = new ArrayCollection();
  135.         $this->userProducts = new ArrayCollection();
  136.         $this->defiAnswerUsers = new ArrayCollection();
  137.         $this->contacts = new ArrayCollection();
  138.         $this->diagAnswerUsers = new ArrayCollection();
  139.     }
  140.     public function getId(): ?int
  141.     {
  142.         return $this->id;
  143.     }
  144.     public function getEmail(): ?string
  145.     {
  146.         return $this->email;
  147.     }
  148.     public function setEmail(string $email): self
  149.     {
  150.         $this->email $email;
  151.         return $this;
  152.     }
  153.     /**
  154.      * A visual identifier that represents this user.
  155.      *
  156.      * @see UserInterface
  157.      */
  158.     public function getUserIdentifier(): string
  159.     {
  160.         return (string) $this->email;
  161.     }
  162.     /**
  163.      * @deprecated since Symfony 5.3, use getUserIdentifier instead
  164.      */
  165.     public function getUsername(): string
  166.     {
  167.         return (string) $this->email;
  168.     }
  169.     /**
  170.      * @see UserInterface
  171.      */
  172.     public function getRoles(): array
  173.     {
  174.         $roles $this->roles;
  175.         // guarantee every user at least has ROLE_USER
  176.         $roles[] = 'ROLE_USER';
  177.         return array_unique($roles);
  178.     }
  179.     public function setRoles(array $roles): self
  180.     {
  181.         $this->roles $roles;
  182.         return $this;
  183.     }
  184.     /**
  185.      * @see PasswordAuthenticatedUserInterface
  186.      */
  187.     public function getPassword(): string
  188.     {
  189.         return $this->password;
  190.     }
  191.     public function setPassword(string $password): self
  192.     {
  193.         $this->password $password;
  194.         return $this;
  195.     }
  196.     /**
  197.      * Returning a salt is only needed, if you are not using a modern
  198.      * hashing algorithm (e.g. bcrypt or sodium) in your security.yaml.
  199.      *
  200.      * @see UserInterface
  201.      */
  202.     public function getSalt(): ?string
  203.     {
  204.         return $this->salt;
  205.     }
  206.     /**
  207.      * @see UserInterface
  208.      */
  209.     public function eraseCredentials()
  210.     {
  211.         // If you store any temporary, sensitive data on the user, clear it here
  212.         // $this->plainPassword = null;
  213.     }
  214.     public function isVerified(): bool
  215.     {
  216.         return $this->isVerified;
  217.     }
  218.     public function setIsVerified(bool $isVerified): self
  219.     {
  220.         $this->isVerified $isVerified;
  221.         return $this;
  222.     }
  223.     public function setSalt(string $salt): self
  224.     {
  225.         $this->salt $salt;
  226.         return $this;
  227.     }
  228.     public function getFirstName(): ?string
  229.     {
  230.         return $this->firstName;
  231.     }
  232.     public function setFirstName(string $firstName): self
  233.     {
  234.         $this->firstName $firstName;
  235.         return $this;
  236.     }
  237.     public function getLastName(): ?string
  238.     {
  239.         return $this->lastName;
  240.     }
  241.     public function setLastName(string $lastName): self
  242.     {
  243.         $this->lastName $lastName;
  244.         return $this;
  245.     }
  246.     public function isIsActive(): ?bool
  247.     {
  248.         return $this->isActive;
  249.     }
  250.     public function setIsActive(bool $isActive): self
  251.     {
  252.         $this->isActive $isActive;
  253.         return $this;
  254.     }
  255.     public function getCreatedAt(): ?\DateTimeInterface
  256.     {
  257.         return $this->createdAt;
  258.     }
  259.     public function setCreatedAt(\DateTimeInterface $createdAt): self
  260.     {
  261.         $this->createdAt $createdAt;
  262.         return $this;
  263.     }
  264.     public function getModifiedAt(): ?\DateTimeInterface
  265.     {
  266.         return $this->modifiedAt;
  267.     }
  268.     public function setModifiedAt(\DateTimeInterface $modifiedAt): self
  269.     {
  270.         $this->modifiedAt $modifiedAt;
  271.         return $this;
  272.     }
  273.     public function getRecentlyLoggedAt(): ?\DateTimeInterface
  274.     {
  275.         return $this->recentlyLoggedAt;
  276.     }
  277.     public function setRecentlyLoggedAt(?\DateTimeInterface $recentlyLoggedAt): self
  278.     {
  279.         $this->recentlyLoggedAt $recentlyLoggedAt;
  280.         return $this;
  281.     }
  282.     public function getDisabledAt(): ?\DateTimeInterface
  283.     {
  284.         return $this->disabledAt;
  285.     }
  286.     public function setDisabledAt(?\DateTimeInterface $disabledAt): self
  287.     {
  288.         $this->disabledAt $disabledAt;
  289.         return $this;
  290.     }
  291.     /**
  292.      * @return Collection<int, FlashUserWorkshop>
  293.      */
  294.     public function getFlashUserWorkshops(): Collection
  295.     {
  296.         return $this->flashUserWorkshops;
  297.     }
  298.     public function addFlashUserWorkshop(FlashUserWorkshop $flashUserWorkshop): self
  299.     {
  300.         if (!$this->flashUserWorkshops->contains($flashUserWorkshop)) {
  301.             $this->flashUserWorkshops[] = $flashUserWorkshop;
  302.             $flashUserWorkshop->setUser($this);
  303.         }
  304.         return $this;
  305.     }
  306.     public function removeFlashUserWorkshop(FlashUserWorkshop $flashUserWorkshop): self
  307.     {
  308.         if ($this->flashUserWorkshops->removeElement($flashUserWorkshop)) {
  309.             // set the owning side to null (unless already changed)
  310.             if ($flashUserWorkshop->getUser() === $this) {
  311.                 $flashUserWorkshop->setUser(null);
  312.             }
  313.         }
  314.         return $this;
  315.     }
  316.     public function getJobTitle(): ?string
  317.     {
  318.         return $this->jobTitle;
  319.     }
  320.     public function setJobTitle(string $jobTitle null): self
  321.     {
  322.         $this->jobTitle $jobTitle;
  323.         return $this;
  324.     }
  325.     /**
  326.      * @return Collection<int, Job>
  327.      */
  328.     public function getJob(): Collection
  329.     {
  330.         return $this->job;
  331.     }
  332.     public function addJob(Job $job): self
  333.     {
  334.         if (!$this->job->contains($job)) {
  335.             $this->job[] = $job;
  336.         }
  337.         return $this;
  338.     }
  339.     public function removeJob(Job $job): self
  340.     {
  341.         $this->job->removeElement($job);
  342.         return $this;
  343.     }
  344.     /**
  345.      * @return Collection<int, Subject>
  346.      */
  347.     public function getSubject(): Collection
  348.     {
  349.         return $this->subject;
  350.     }
  351.     public function addSubject(Subject $subject): self
  352.     {
  353.         if (!$this->subject->contains($subject)) {
  354.             $this->subject[] = $subject;
  355.         }
  356.         return $this;
  357.     }
  358.     public function removeSubject(Subject $subject): self
  359.     {
  360.         $this->subject->removeElement($subject);
  361.         return $this;
  362.     }
  363.     public function getLocation(): ?Location
  364.     {
  365.         return $this->location;
  366.     }
  367.     public function setLocation(?Location $location): self
  368.     {
  369.         $this->location $location;
  370.         return $this;
  371.     }
  372.     public function getSubLocation(): ?SubLocation
  373.     {
  374.         return $this->subLocation;
  375.     }
  376.     public function setSubLocation(?SubLocation $subLocation): self
  377.     {
  378.         $this->subLocation $subLocation;
  379.         return $this;
  380.     }
  381.     public function getClient(): ?Client
  382.     {
  383.         return $this->client;
  384.     }
  385.     public function setClient(?Client $client): self
  386.     {
  387.         $this->client $client;
  388.         return $this;
  389.     }
  390.     /**
  391.      * @return Collection<int, UserProduct>
  392.      */
  393.     public function getUserProducts(): Collection
  394.     {
  395.         return $this->userProducts;
  396.     }
  397.     public function addUserProduct(UserProduct $userProduct): self
  398.     {
  399.         if (!$this->userProducts->contains($userProduct)) {
  400.             $this->userProducts[] = $userProduct;
  401.             $userProduct->setUser($this);
  402.         }
  403.         return $this;
  404.     }
  405.     public function removeUserProduct(UserProduct $userProduct): self
  406.     {
  407.         if ($this->userProducts->removeElement($userProduct)) {
  408.             // set the owning side to null (unless already changed)
  409.             if ($userProduct->getUser() === $this) {
  410.                 $userProduct->setUser(null);
  411.             }
  412.         }
  413.         return $this;
  414.     }
  415.     /**
  416.      * @return Collection<int, DefiAnswerUser>
  417.      */
  418.     public function getDefiAnswerUsers(): Collection
  419.     {
  420.         return $this->defiAnswerUsers;
  421.     }
  422.     public function addDefiAnswerUser(DefiAnswerUser $defiAnswerUser): self
  423.     {
  424.         if (!$this->defiAnswerUsers->contains($defiAnswerUser)) {
  425.             $this->defiAnswerUsers[] = $defiAnswerUser;
  426.             $defiAnswerUser->setUser($this);
  427.         }
  428.         return $this;
  429.     }
  430.     public function removeDefiAnswerUser(DefiAnswerUser $defiAnswerUser): self
  431.     {
  432.         if ($this->defiAnswerUsers->removeElement($defiAnswerUser)) {
  433.             // set the owning side to null (unless already changed)
  434.             if ($defiAnswerUser->getUser() === $this) {
  435.                 $defiAnswerUser->setUser(null);
  436.             }
  437.         }
  438.         return $this;
  439.     }
  440.     public function getIcon(): ?string
  441.     {
  442.         return $this->icon;
  443.     }
  444.     public function setIcon(?string $icon): self
  445.     {
  446.         $this->icon $icon;
  447.         return $this;
  448.     }
  449.     /**
  450.      * @return Collection<int, Contact>
  451.      */
  452.     public function getContacts(): Collection
  453.     {
  454.         return $this->contacts;
  455.     }
  456.     public function addContact(Contact $contact): self
  457.     {
  458.         if (!$this->contacts->contains($contact)) {
  459.             $this->contacts[] = $contact;
  460.             $contact->setUser($this);
  461.         }
  462.         return $this;
  463.     }
  464.     public function removeContact(Contact $contact): self
  465.     {
  466.         if ($this->contacts->removeElement($contact)) {
  467.             // set the owning side to null (unless already changed)
  468.             if ($contact->getUser() === $this) {
  469.                 $contact->setUser(null);
  470.             }
  471.         }
  472.         return $this;
  473.     }
  474.     public function getAvatar(): ?Avatar
  475.     {
  476.         return $this->avatar;
  477.     }
  478.     public function setAvatar(?Avatar $avatar): self
  479.     {
  480.         $this->avatar $avatar;
  481.         return $this;
  482.     }
  483.     public function getAge(): ?string
  484.     {
  485.         return $this->age;
  486.     }
  487.     public function setAge(?string $age): self
  488.     {
  489.         $this->age $age;
  490.         return $this;
  491.     }
  492.     /**
  493.      * @return Collection<int, DiagAnswerUser>
  494.      */
  495.     public function getDiagAnswerUsers(): Collection
  496.     {
  497.         return $this->diagAnswerUsers;
  498.     }
  499.     public function addDiagAnswerUser(DiagAnswerUser $diagAnswerUser): self
  500.     {
  501.         if (!$this->diagAnswerUsers->contains($diagAnswerUser)) {
  502.             $this->diagAnswerUsers[] = $diagAnswerUser;
  503.             $diagAnswerUser->setUser($this);
  504.         }
  505.         return $this;
  506.     }
  507.     public function removeDiagAnswerUser(DiagAnswerUser $diagAnswerUser): self
  508.     {
  509.         if ($this->diagAnswerUsers->removeElement($diagAnswerUser)) {
  510.             // set the owning side to null (unless already changed)
  511.             if ($diagAnswerUser->getUser() === $this) {
  512.                 $diagAnswerUser->setUser(null);
  513.             }
  514.         }
  515.         return $this;
  516.     }
  517. }