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 Ramsey\Uuid\Doctrine\UuidGenerator;
  8. use Ramsey\Uuid\UuidInterface;
  9. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  10. use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
  11. use Symfony\Component\Security\Core\User\UserInterface;
  12. #[ORM\Entity(repositoryClassUserRepository::class)]
  13. #[UniqueEntity('email')]
  14. class User implements UserInterfacePasswordAuthenticatedUserInterface
  15. {
  16.     #[ORM\Id]
  17.     #[ORM\Column(type"uuid"uniquetrue)]
  18.     #[ORM\GeneratedValue(strategy"CUSTOM")]
  19.     #[ORM\CustomIdGenerator(class: UuidGenerator::class)]
  20.     protected UuidInterface|string $id;
  21.     #[ORM\Column(length255)]
  22.     private ?string $firstName null;
  23.     #[ORM\Column(length255)]
  24.     private ?string $lastName null;
  25.     #[ORM\Column(length255uniquetrue)]
  26.     private ?string $email null;
  27.     #[ORM\Column(length255)]
  28.     private ?string $password null;
  29.     #[ORM\Column]
  30.     private ?bool $enabled true;
  31.     #[ORM\OneToMany(mappedBy'user'targetEntityLocation::class, cascade: ['persist'], orphanRemovaltrue)]
  32.     private Collection $locations;
  33.     #[ORM\Column]
  34.     private ?\DateTimeImmutable $createdAt null;
  35.     #[ORM\Column(length255nullabletrue)]
  36.     private ?string $phone null;
  37.     #[ORM\Column]
  38.     private ?bool $emailVerified false;
  39.     #[ORM\Column(length255nullabletrue)]
  40.     private ?string $resetPasswordToken;
  41.     #[ORM\Column(nullabletrue)]
  42.     private ?\DateTimeImmutable $resetPasswordRequestAt null;
  43.     #[ORM\OneToMany(mappedBy'customer'targetEntitySubscription::class)]
  44.     private Collection $subscriptions;
  45.     #[ORM\Column]
  46.     private ?bool $isAdmin null;
  47.     public function __construct()
  48.     {
  49.         $this->locations = new ArrayCollection();
  50.         $this->createdAt $this->createdAt ?? new \DateTimeImmutable();
  51.         $this->subscriptions = new ArrayCollection();
  52.     }
  53.     public function getId(): ?string
  54.     {
  55.         return $this->id;
  56.     }
  57.     public function getEmail(): ?string
  58.     {
  59.         return $this->email;
  60.     }
  61.     public function setEmail(string $email): self
  62.     {
  63.         $this->email $email;
  64.         return $this;
  65.     }
  66.     public function getPassword(): ?string
  67.     {
  68.         return $this->password;
  69.     }
  70.     public function setPassword(string $password): self
  71.     {
  72.         $this->password $password;
  73.         return $this;
  74.     }
  75.     public function isEnabled(): ?bool
  76.     {
  77.         return $this->enabled;
  78.     }
  79.     public function setEnabled(bool $enabled): self
  80.     {
  81.         $this->enabled $enabled;
  82.         return $this;
  83.     }
  84.     public function getUserIdentifier()
  85.     {
  86.         return $this->email;
  87.     }
  88.     public function getRoles()
  89.     {
  90.         $roles[] = 'ROLE_USER';
  91.         if ($this->isAdmin) {
  92.             $roles[] = 'ROLE_ADMIN';
  93.         }
  94.         return $roles;
  95.     }
  96.     public function getSalt()
  97.     {
  98.         // TODO: Implement getSalt() method.
  99.     }
  100.     public function eraseCredentials()
  101.     {
  102.         // TODO: Implement eraseCredentials() method.
  103.     }
  104.     public function getUsername()
  105.     {
  106.         return $this->email;
  107.     }
  108.     /**
  109.      * @return Collection<int, Location>
  110.      */
  111.     public function getLocations(): Collection
  112.     {
  113.         return $this->locations;
  114.     }
  115.     public function addLocation(Location $location): self
  116.     {
  117.         if (!$this->locations->contains($location)) {
  118.             $this->locations->add($location);
  119.             $location->setUser($this);
  120.         }
  121.         return $this;
  122.     }
  123.     public function removeLocation(Location $location): self
  124.     {
  125.         if ($this->locations->removeElement($location)) {
  126.             // set the owning side to null (unless already changed)
  127.             if ($location->getUser() === $this) {
  128.                 $location->setUser(null);
  129.             }
  130.         }
  131.         return $this;
  132.     }
  133.     public function getCreatedAt(): ?\DateTimeImmutable
  134.     {
  135.         return $this->createdAt;
  136.     }
  137.     public function setCreatedAt(\DateTimeImmutable $createdAt): self
  138.     {
  139.         $this->createdAt $createdAt;
  140.         return $this;
  141.     }
  142.     public function getFullName(): ?string
  143.     {
  144.         return $this->fullName;
  145.     }
  146.     public function setFullName(?string $fullName): self
  147.     {
  148.         $this->fullName $fullName;
  149.         return $this;
  150.     }
  151.     public function getPhone(): ?string
  152.     {
  153.         return $this->phone;
  154.     }
  155.     public function setPhone(?string $phone): self
  156.     {
  157.         $this->phone $phone;
  158.         return $this;
  159.     }
  160.     public function getEmailVerified(): ?bool
  161.     {
  162.         return $this->emailVerified;
  163.     }
  164.     public function setEmailVerified(?bool $emailVerified): self
  165.     {
  166.         $this->emailVerified $emailVerified;
  167.         return $this;
  168.     }
  169.     public function getResetPasswordToken(): ?string
  170.     {
  171.         return $this->resetPasswordToken;
  172.     }
  173.     public function setResetPasswordToken(?string $resetPasswordToken): self
  174.     {
  175.         $this->resetPasswordToken $resetPasswordToken;
  176.         return $this;
  177.     }
  178.     public function getResetPasswordRequestAt(): ?\DateTimeImmutable
  179.     {
  180.         return $this->resetPasswordRequestAt;
  181.     }
  182.     public function setResetPasswordRequestAt(?\DateTimeImmutable $resetPasswordRequestAt): self
  183.     {
  184.         $this->resetPasswordRequestAt $resetPasswordRequestAt;
  185.         return $this;
  186.     }
  187.     /**
  188.      * @return Collection<int, Subscription>
  189.      */
  190.     public function getSubscriptions(): Collection
  191.     {
  192.         return $this->subscriptions;
  193.     }
  194.     public function addSubscription(Subscription $subscription): static
  195.     {
  196.         if (!$this->subscriptions->contains($subscription)) {
  197.             $this->subscriptions->add($subscription);
  198.             $subscription->setCustomer($this);
  199.         }
  200.         return $this;
  201.     }
  202.     public function removeSubscription(Subscription $subscription): static
  203.     {
  204.         if ($this->subscriptions->removeElement($subscription)) {
  205.             // set the owning side to null (unless already changed)
  206.             if ($subscription->getCustomer() === $this) {
  207.                 $subscription->setCustomer(null);
  208.             }
  209.         }
  210.         return $this;
  211.     }
  212.     public function getFirstName(): ?string
  213.     {
  214.         return $this->firstName;
  215.     }
  216.     public function setFirstName(string $firstName): static
  217.     {
  218.         $this->firstName $firstName;
  219.         return $this;
  220.     }
  221.     public function getLastName(): ?string
  222.     {
  223.         return $this->lastName;
  224.     }
  225.     public function setLastName(string $lastName): static
  226.     {
  227.         $this->lastName $lastName;
  228.         return $this;
  229.     }
  230.     public function isIsAdmin(): ?bool
  231.     {
  232.         return $this->isAdmin;
  233.     }
  234.     public function setIsAdmin(bool $isAdmin): static
  235.     {
  236.         $this->isAdmin $isAdmin;
  237.         return $this;
  238.     }
  239. }