src/Entity/User.php line 16

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. #[ORM\Entity(repositoryClassUserRepository::class)]
  11. #[UniqueEntity(fields: ['email'], message'There is already an account with this email')]
  12. #[UniqueEntity(fields: ['slug'])]
  13. class User implements UserInterfacePasswordAuthenticatedUserInterface
  14. {
  15.     #[ORM\Id]
  16.     #[ORM\GeneratedValue]
  17.     #[ORM\Column]
  18.     private ?int $id null;
  19.     #[ORM\Column(length180uniquetrue)]
  20.     private ?string $email null;
  21.     #[ORM\Column]
  22.     private array $roles = [];
  23.     /**
  24.      * @var string The hashed password
  25.      */
  26.     #[ORM\Column]
  27.     private ?string $password null;
  28.     #[ORM\Column(length255)]
  29.     private ?string $name null;
  30.     #[ORM\Column(length255)]
  31.     private ?string $surname null;
  32.     #[ORM\Column(length255)]
  33.     private ?string $country null;
  34.     #[ORM\Column(length255)]
  35.     private ?string $city null;
  36.     #[ORM\Column(length255)]
  37.     private ?string $address null;
  38.     #[ORM\Column(length255)]
  39.     private ?string $passport null;
  40.     #[ORM\Column(length255)]
  41.     private ?string $slug null;
  42.     #[ORM\OneToMany(mappedBy'user'targetEntityVisit::class)]
  43.     private Collection $visits;
  44.     #[ORM\Column(length255)]
  45.     private ?string $locale null;
  46.     #[ORM\Column(type'boolean')]
  47.     private ?bool $isVerified false;
  48.     #[ORM\Column(length255nullabletrue)]
  49.     private ?string $instagram null;
  50.     #[ORM\Column(length255nullabletrue)]
  51.     private ?string $twitter null;
  52.     #[ORM\Column(length255nullabletrue)]
  53.     private ?string $tiktok null;
  54.     #[ORM\Column(options: ['default' => '1970-01-02'])]
  55.     private ?\DateTimeImmutable $signupDate null;
  56.     #[ORM\Column]
  57.     private ?bool $isBanned false;
  58.     #[ORM\Column(nullabletrue)]
  59.     private ?\DateTimeImmutable $bannedDate null;
  60.     #[ORM\ManyToOne(targetEntityself::class)]
  61.     private ?self $bannedBy null;
  62.     public function __construct()
  63.     {
  64.         $this->visits = new ArrayCollection();
  65.     }
  66.     public function getId(): ?int
  67.     {
  68.         return $this->id;
  69.     }
  70.     public function getEmail(): ?string
  71.     {
  72.         return $this->email;
  73.     }
  74.     public function setEmail(string $email): self
  75.     {
  76.         $this->email $email;
  77.         return $this;
  78.     }
  79.     /**
  80.      * A visual identifier that represents this user.
  81.      *
  82.      * @see UserInterface
  83.      */
  84.     public function getUserIdentifier(): string
  85.     {
  86.         return (string) $this->email;
  87.     }
  88.     /**
  89.      * @deprecated since Symfony 5.3, use getUserIdentifier instead
  90.      */
  91.     public function getUsername(): string
  92.     {
  93.         return (string) $this->email;
  94.     }
  95.     /**
  96.      * @see UserInterface
  97.      */
  98.     public function getRoles(): array
  99.     {
  100.         $roles $this->roles;
  101.         // guarantee every user at least has ROLE_USER
  102.         $roles[] = 'ROLE_USER';
  103.         return array_unique($roles);
  104.     }
  105.     public function hasRole(string $role): bool
  106.     {
  107.         return in_array($role$this->getRoles());
  108.     }
  109.     public function setRoles(array $roles): self
  110.     {
  111.         $this->roles $roles;
  112.         return $this;
  113.     }
  114.     /**
  115.      * @see PasswordAuthenticatedUserInterface
  116.      */
  117.     public function getPassword(): string
  118.     {
  119.         return $this->password;
  120.     }
  121.     public function setPassword(string $password): self
  122.     {
  123.         $this->password $password;
  124.         return $this;
  125.     }
  126.     /**
  127.      * Returning a salt is only needed, if you are not using a modern
  128.      * hashing algorithm (e.g. bcrypt or sodium) in your security.yaml.
  129.      *
  130.      * @see UserInterface
  131.      */
  132.     public function getSalt(): ?string
  133.     {
  134.         return null;
  135.     }
  136.     /**
  137.      * @see UserInterface
  138.      */
  139.     public function eraseCredentials()
  140.     {
  141.         // If you store any temporary, sensitive data on the user, clear it here
  142.         // $this->plainPassword = null;
  143.     }
  144.     public function getName(): ?string
  145.     {
  146.         return $this->name;
  147.     }
  148.     public function setName(string $name): self
  149.     {
  150.         $this->name $name;
  151.         return $this;
  152.     }
  153.     public function getSurname(): ?string
  154.     {
  155.         return $this->surname;
  156.     }
  157.     public function setSurname(string $surname): self
  158.     {
  159.         $this->surname $surname;
  160.         return $this;
  161.     }
  162.     public function getCountry(): ?string
  163.     {
  164.         return $this->country;
  165.     }
  166.     public function setCountry(string $country): self
  167.     {
  168.         $this->country $country;
  169.         return $this;
  170.     }
  171.     public function getCity(): ?string
  172.     {
  173.         return $this->city;
  174.     }
  175.     public function setCity(string $city): self
  176.     {
  177.         $this->city $city;
  178.         return $this;
  179.     }
  180.     public function getAddress(): ?string
  181.     {
  182.         return $this->address;
  183.     }
  184.     public function setAddress(string $address): self
  185.     {
  186.         $this->address $address;
  187.         return $this;
  188.     }
  189.     public function getPassport(): ?string
  190.     {
  191.         return $this->passport;
  192.     }
  193.     public function setPassport(string $passport): self
  194.     {
  195.         $this->passport $passport;
  196.         return $this;
  197.     }
  198.     public function getSlug(): ?string
  199.     {
  200.         return $this->slug;
  201.     }
  202.     public function setSlug(string $slug): self
  203.     {
  204.         $this->slug $slug;
  205.         return $this;
  206.     }
  207.     /**
  208.      * @return Collection<int, Visit>
  209.      */
  210.     public function getVisits(): Collection
  211.     {
  212.         return $this->visits;
  213.     }
  214.     public function addVisit(Visit $visit): self
  215.     {
  216.         if (!$this->visits->contains($visit)) {
  217.             $this->visits->add($visit);
  218.             $visit->setUser($this);
  219.         }
  220.         return $this;
  221.     }
  222.     public function removeVisit(Visit $visit): self
  223.     {
  224.         if ($this->visits->removeElement($visit)) {
  225.             // set the owning side to null (unless already changed)
  226.             if ($visit->getUser() === $this) {
  227.                 $visit->setUser(null);
  228.             }
  229.         }
  230.         return $this;
  231.     }
  232.     public function getLocale(): ?string
  233.     {
  234.         return $this->locale;
  235.     }
  236.     public function setLocale(string $locale): self
  237.     {
  238.         $this->locale $locale;
  239.         return $this;
  240.     }
  241.     public function isVerified(): bool
  242.     {
  243.         return $this->isVerified;
  244.     }
  245.     public function setIsVerified(bool $isVerified): self
  246.     {
  247.         $this->isVerified $isVerified;
  248.         return $this;
  249.     }
  250.     public function getInstagram(): ?string
  251.     {
  252.         return $this->instagram;
  253.     }
  254.     public function setInstagram(?string $instagram): self
  255.     {
  256.         $this->instagram $instagram;
  257.         return $this;
  258.     }
  259.     public function getTwitter(): ?string
  260.     {
  261.         return $this->twitter;
  262.     }
  263.     public function setTwitter(?string $twitter): self
  264.     {
  265.         $this->twitter $twitter;
  266.         return $this;
  267.     }
  268.     public function getTiktok(): ?string
  269.     {
  270.         return $this->tiktok;
  271.     }
  272.     public function setTiktok(?string $tiktok): self
  273.     {
  274.         $this->tiktok $tiktok;
  275.         return $this;
  276.     }
  277.     public function getSignupDate(): ?\DateTimeImmutable
  278.     {
  279.         return $this->signupDate;
  280.     }
  281.     public function setSignupDate(\DateTimeImmutable $signupDate): self
  282.     {
  283.         $this->signupDate $signupDate;
  284.         return $this;
  285.     }
  286.     public function isIsBanned(): ?bool
  287.     {
  288.         return $this->isBanned;
  289.     }
  290.     public function setIsBanned(bool $isBanned): self
  291.     {
  292.         $this->isBanned $isBanned;
  293.         return $this;
  294.     }
  295.     public function getBannedDate(): ?\DateTimeImmutable
  296.     {
  297.         return $this->bannedDate;
  298.     }
  299.     public function setBannedDate(?\DateTimeImmutable $bannedDate): self
  300.     {
  301.         $this->bannedDate $bannedDate;
  302.         return $this;
  303.     }
  304.     public function getBannedBy(): ?self
  305.     {
  306.         return $this->bannedBy;
  307.     }
  308.     public function setBannedBy(?self $bannedBy): self
  309.     {
  310.         $this->bannedBy $bannedBy;
  311.         return $this;
  312.     }
  313.     public function isIsVerified(): ?bool
  314.     {
  315.         return $this->isVerified;
  316.     }
  317. }