src/Entity/User.php line 14

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 Doctrine\ORM\Mapping\JoinTable;
  8. use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
  9. use Symfony\Component\Security\Core\User\UserInterface;
  10. #[ORM\Entity(repositoryClassUserRepository::class)]
  11. class User implements UserInterfacePasswordAuthenticatedUserInterface
  12. {
  13.     #[ORM\Id]
  14.     #[ORM\GeneratedValue]
  15.     #[ORM\Column]
  16.     private ?int $id null;
  17.     #[ORM\Column(length180uniquetrue)]
  18.     private ?string $email null;
  19.     #[ORM\Column]
  20.     private array $roles = [];
  21.     /**
  22.      * @var string The hashed password
  23.      */
  24.     #[ORM\Column]
  25.     private ?string $password null;
  26.     #[ORM\Column(length100)]
  27.     private ?string $name null;
  28.     #[ORM\Column(length200)]
  29.     private ?string $firstname null;
  30.     #[ORM\Column(length255nullabletrue)]
  31.     private ?string $logo null;
  32.     #[ORM\Column]
  33.     private ?\DateTimeImmutable $createdAt null;
  34.     #[ORM\Column(nullabletrue)]
  35.     private ?\DateTimeImmutable $updatedAt null;
  36.     #[ORM\ManyToOne(inversedBy'users')]
  37.     private ?Company $company null;
  38.     #[ORM\ManyToMany(targetEntityProject::class, mappedBy'user')]
  39.     #[ORM\OrderBy(["id"=>'DESC'])]
  40.     private Collection $projects;
  41.     #[ORM\OneToMany(mappedBy'user'targetEntityLogs::class, cascade:['remove'])]
  42.     #[ORM\OrderBy(['id'=>'DESC'])]
  43.     private Collection $logs;
  44.     #[ORM\OneToMany(mappedBy'user'targetEntityNotification::class, cascade:['remove'])]
  45.     private Collection $notifications;
  46.     #[ORM\ManyToMany(targetEntityProject::class, mappedBy'admin')]
  47.     private Collection $adminProjects;
  48.     #[ORM\OneToOne(mappedBy'user'cascade: ['persist''remove'])]
  49.     private ?UpdatePassword $updatePassword null;
  50.     #[ORM\OneToMany(mappedBy'user'targetEntityConnectionHistory::class, cascade:['remove'])]
  51.     private Collection $connectionHistories;
  52.     #[ORM\Column(nullabletrue)]
  53.     private ?string $phone_number null;
  54.     #[ORM\ManyToMany(targetEntityProject::class, mappedBy'contact')]
  55.     private Collection $contact;
  56.     #[ORM\Column]
  57.     private ?bool $isPasswordChanged null;
  58.     public function __construct()
  59.     {
  60.         $this->projects = new ArrayCollection();
  61.         $this->logs = new ArrayCollection();
  62.         $this->notifications = new ArrayCollection();
  63.         $this->adminProjects = new ArrayCollection();
  64.         $this->connectionHistories = new ArrayCollection();
  65.         $this->contact = new ArrayCollection();
  66.     }
  67.     public function getId(): ?int
  68.     {
  69.         return $this->id;
  70.     }
  71.     public function getEmail(): ?string
  72.     {
  73.         return $this->email;
  74.     }
  75.     public function setEmail(string $email): self
  76.     {
  77.         $this->email $email;
  78.         return $this;
  79.     }
  80.     /**
  81.      * A visual identifier that represents this user.
  82.      *
  83.      * @see UserInterface
  84.      */
  85.     public function getUserIdentifier(): string
  86.     {
  87.         return (string) $this->email;
  88.     }
  89.     /**
  90.      * @deprecated since Symfony 5.3, use getUserIdentifier instead
  91.      */
  92.     public function getUsername(): string
  93.     {
  94.         return (string) $this->email;
  95.     }
  96.     /**
  97.      * @see UserInterface
  98.      */
  99.     public function getRoles(): array
  100.     {
  101.         $roles $this->roles;
  102.         // guarantee every user at least has ROLE_USER
  103.         return array_unique($roles);
  104.     }
  105.     public function setRoles(array $roles): self
  106.     {
  107.         $this->roles $roles;
  108.         return $this;
  109.     }
  110.     /**
  111.      * @see PasswordAuthenticatedUserInterface
  112.      */
  113.     public function getPassword(): string
  114.     {
  115.         return $this->password;
  116.     }
  117.     public function setPassword(string $password): self
  118.     {
  119.         $this->password $password;
  120.         return $this;
  121.     }
  122.     /**
  123.      * Returning a salt is only needed, if you are not using a modern
  124.      * hashing algorithm (e.g. bcrypt or sodium) in your security.yaml.
  125.      *
  126.      * @see UserInterface
  127.      */
  128.     public function getSalt(): ?string
  129.     {
  130.         return null;
  131.     }
  132.     /**
  133.      * @see UserInterface
  134.      */
  135.     public function eraseCredentials()
  136.     {
  137.         // If you store any temporary, sensitive data on the user, clear it here
  138.         // $this->plainPassword = null;
  139.     }
  140.     public function getName(): ?string
  141.     {
  142.         return $this->name;
  143.     }
  144.     public function setName(string $name): self
  145.     {
  146.         $this->name $name;
  147.         return $this;
  148.     }
  149.     public function getFirstname(): ?string
  150.     {
  151.         return $this->firstname;
  152.     }
  153.     public function setFirstname(string $firstname): self
  154.     {
  155.         $this->firstname $firstname;
  156.         return $this;
  157.     }
  158.     public function getLogo(): ?string
  159.     {
  160.         return $this->logo;
  161.     }
  162.     public function setLogo(?string $logo): self
  163.     {
  164.         $this->logo $logo;
  165.         return $this;
  166.     }
  167.     public function getCreatedAt(): ?\DateTimeImmutable
  168.     {
  169.         return $this->createdAt;
  170.     }
  171.     public function setCreatedAt(\DateTimeImmutable $createdAt): self
  172.     {
  173.         $this->createdAt $createdAt;
  174.         return $this;
  175.     }
  176.     public function getUpdatedAt(): ?\DateTimeImmutable
  177.     {
  178.         return $this->updatedAt;
  179.     }
  180.     public function setUpdatedAt(?\DateTimeImmutable $updatedAt): self
  181.     {
  182.         $this->updatedAt $updatedAt;
  183.         return $this;
  184.     }
  185.     public function __toString()
  186.     {
  187.         return $this->name $this->firstname '|';
  188.     }
  189.     public function getCompany(): ?Company
  190.     {
  191.         return $this->company;
  192.     }
  193.     public function setCompany(?Company $company): self
  194.     {
  195.         $this->company $company;
  196.         return $this;
  197.     }
  198.     /**
  199.      * @return Collection<int, Project>
  200.      */
  201.     public function getProjects(): Collection
  202.     {
  203.         return $this->projects;
  204.     }
  205.     public function addProject(Project $project): self
  206.     {
  207.         if (!$this->projects->contains($project)) {
  208.             $this->projects->add($project);
  209.             $project->addUser($this);
  210.         }
  211.         return $this;
  212.     }
  213.     public function removeProject(Project $project): self
  214.     {
  215.         if ($this->projects->removeElement($project)) {
  216.             $project->removeUser($this);
  217.         }
  218.         return $this;
  219.     }
  220.     /**
  221.      * @return Collection<int, Logs>
  222.      */
  223.     public function getLogs(): Collection
  224.     {
  225.         return $this->logs;
  226.     }
  227.     public function addLog(Logs $log): self
  228.     {
  229.         if (!$this->logs->contains($log)) {
  230.             $this->logs->add($log);
  231.             $log->setUser($this);
  232.         }
  233.         return $this;
  234.     }
  235.     public function removeLog(Logs $log): self
  236.     {
  237.         if ($this->logs->removeElement($log)) {
  238.             // set the owning side to null (unless already changed)
  239.             if ($log->getUser() === $this) {
  240.                 $log->setUser(null);
  241.             }
  242.         }
  243.         return $this;
  244.     }
  245.     /**
  246.      * @return Collection<int, Notification>
  247.      */
  248.     public function getNotifications(): Collection
  249.     {
  250.         return $this->notifications;
  251.     }
  252.     public function addNotification(Notification $notification): self
  253.     {
  254.         if (!$this->notifications->contains($notification)) {
  255.             $this->notifications->add($notification);
  256.             $notification->setUser($this);
  257.         }
  258.         return $this;
  259.     }
  260.     public function removeNotification(Notification $notification): self
  261.     {
  262.         if ($this->notifications->removeElement($notification)) {
  263.             // set the owning side to null (unless already changed)
  264.             if ($notification->getUser() === $this) {
  265.                 $notification->setUser(null);
  266.             }
  267.         }
  268.         return $this;
  269.     }
  270.     /**
  271.      * @return Collection<int, Project>
  272.      */
  273.     public function getAdminProjects(): Collection
  274.     {
  275.         return $this->adminProjects;
  276.     }
  277.     public function addAdminProject(Project $adminProject): self
  278.     {
  279.         if (!$this->adminProjects->contains($adminProject)) {
  280.             $this->adminProjects->add($adminProject);
  281.             $adminProject->addAdmin($this);
  282.         }
  283.         return $this;
  284.     }
  285.     public function removeAdminProject(Project $adminProject): self
  286.     {
  287.         if ($this->adminProjects->removeElement($adminProject)) {
  288.             $adminProject->removeAdmin($this);
  289.         }
  290.         return $this;
  291.     }
  292.     public function getUpdatePassword(): ?UpdatePassword
  293.     {
  294.         return $this->updatePassword;
  295.     }
  296.     public function setUpdatePassword(UpdatePassword $updatePassword): self
  297.     {
  298.         // set the owning side of the relation if necessary
  299.         if ($updatePassword->getUser() !== $this) {
  300.             $updatePassword->setUser($this);
  301.         }
  302.         $this->updatePassword $updatePassword;
  303.         return $this;
  304.     }
  305.     /**
  306.      * @return Collection<int, ConnectionHistory>
  307.      */
  308.     public function getConnectionHistories(): Collection
  309.     {
  310.         return $this->connectionHistories;
  311.     }
  312.     public function addConnectionHistory(ConnectionHistory $connectionHistory): self
  313.     {
  314.         if (!$this->connectionHistories->contains($connectionHistory)) {
  315.             $this->connectionHistories->add($connectionHistory);
  316.             $connectionHistory->setUser($this);
  317.         }
  318.         return $this;
  319.     }
  320.     public function removeConnectionHistory(ConnectionHistory $connectionHistory): self
  321.     {
  322.         if ($this->connectionHistories->removeElement($connectionHistory)) {
  323.             // set the owning side to null (unless already changed)
  324.             if ($connectionHistory->getUser() === $this) {
  325.                 $connectionHistory->setUser(null);
  326.             }
  327.         }
  328.         return $this;
  329.     }
  330.     public function getPhoneNumber(): ?string
  331.     {
  332.         return $this->phone_number;
  333.     }
  334.     public function setPhoneNumber(?string $phone_number): self
  335.     {
  336.         $this->phone_number $phone_number;
  337.         return $this;
  338.     }
  339.     /**
  340.      * @return Collection<int, Project>
  341.      */
  342.     public function getContact(): Collection
  343.     {
  344.         return $this->contact;
  345.     }
  346.     public function addContact(Project $contact): self
  347.     {
  348.         if (!$this->contact->contains($contact)) {
  349.             $this->contact->add($contact);
  350.             $contact->addContact($this);
  351.         }
  352.         return $this;
  353.     }
  354.     public function removeContact(Project $contact): self
  355.     {
  356.         if ($this->contact->removeElement($contact)) {
  357.             $contact->removeContact($this);
  358.         }
  359.         return $this;
  360.     }
  361.     public function isIsPasswordChanged(): ?bool
  362.     {
  363.         return $this->isPasswordChanged;
  364.     }
  365.     public function setIsPasswordChanged(bool $isPasswordChanged): self
  366.     {
  367.         $this->isPasswordChanged $isPasswordChanged;
  368.         return $this;
  369.     }
  370. }