src/Entity/User.php line 18

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Constants\ActiveConstants;
  4. use App\Repository\UserRepository;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\DBAL\Types\Types;
  8. use Doctrine\ORM\Mapping as ORM;
  9. use Sonata\UserBundle\Entity\BaseUser;
  10. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  11. use Symfony\Component\Validator\Constraints as Assert;
  12. #[UniqueEntity('email')]
  13. #[ORM\Entity(repositoryClassUserRepository::class)]
  14. #[ORM\HasLifecycleCallbacks]
  15. class User extends BaseUser
  16. {
  17.     #[ORM\Id]
  18.     #[ORM\GeneratedValue]
  19.     #[ORM\Column(type'integer')]
  20.     protected $id;
  21.     #[ORM\Column(name'timezone'type'string'length255nullabletrue)]
  22.     protected ?string $timezone null;
  23.     #[ORM\ManyToMany(targetEntityCompany::class, mappedBy'users')]
  24.     private Collection $companies;
  25.     #[ORM\OneToMany(mappedBy'user'targetEntityPhoneNumber::class)]
  26.     private Collection $phoneNumbers;
  27.     #[ORM\OneToMany(mappedBy'lockedUser'targetEntityPhoneNumber::class)]
  28.     private Collection $lockedPhones;
  29.     #[ORM\OneToMany(mappedBy'user'targetEntityOrder::class)]
  30.     private Collection $orders;
  31.     #[ORM\Column(length191nullabletrue)]
  32.     private ?string $firstName null;
  33.     #[ORM\Column(length191nullabletrue)]
  34.     private ?string $middleName null;
  35.     #[ORM\Column(length191nullabletrue)]
  36.     private ?string $lastName null;
  37.     #[ORM\Column(length191nullabletrue)]
  38.     private ?string $verifyCode null;
  39.     #[ORM\Column(name'email_verified_at'type'datetime'nullabletrue)]
  40.     private $emailVerifiedAt;
  41.     #[ORM\Column(name'code_sent_at'type'datetime'nullabletrue)]
  42.     private $codeSentAt;
  43.     #[ORM\Column(name'generate_phone_hash_at'type'datetime'nullabletrue)]
  44.     private $generatePhoneHashAt;
  45.     #[Assert\NotBlank]
  46.     #[Assert\Email]
  47.     protected ?string $email;
  48.     #[ORM\Column(length191nullabletrue)]
  49.     private ?string $resetHash null;
  50.     #[ORM\Column(length191nullabletrue)]
  51.     private ?string $numberHash null;
  52.     #[ORM\Column(type'text'nullabletrue)]
  53.     private ?string $metaTags null;
  54.     public function __construct()
  55.     {
  56.         $this->companies = new ArrayCollection();
  57.         $this->phoneNumbers = new ArrayCollection();
  58.         $this->orders = new ArrayCollection();
  59.         $this->lockedPhones = new ArrayCollection();
  60.     }
  61.     public function getId(): ?int
  62.     {
  63.         return $this->id;
  64.     }
  65.     public function getTimezone(): ?string
  66.     {
  67.         return $this->timezone;
  68.     }
  69.     public function setTimezone(?string $timezone): self
  70.     {
  71.         $this->timezone $timezone;
  72.         return $this;
  73.     }
  74.     /**
  75.      * @return Collection<int, Company>
  76.      */
  77.     public function getCompanies(): Collection
  78.     {
  79.         return $this->companies;
  80.     }
  81.     public function addCompany(Company $company): static
  82.     {
  83.         if (!$this->companies->contains($company)) {
  84.             $this->companies->add($company);
  85.             $company->addUser($this);
  86.         }
  87.         return $this;
  88.     }
  89.     public function hasCompany(Company $company)
  90.     {
  91.         return $this->companies->contains($company);
  92.     }
  93.     public function removeCompany(Company $company): static
  94.     {
  95.         if ($this->companies->removeElement($company)) {
  96.             $company->removeUser($this);
  97.         }
  98.         return $this;
  99.     }
  100.     /**
  101.      * @return Collection<int, PhoneNumber>
  102.      */
  103.     public function getPhoneNumbers(): Collection
  104.     {
  105.         return $this->phoneNumbers;
  106.     }
  107.     public function addPhoneNumber(PhoneNumber $phoneNumber): static
  108.     {
  109.         if (!$this->phoneNumbers->contains($phoneNumber)) {
  110.             $this->phoneNumbers->add($phoneNumber);
  111.             $phoneNumber->setUser($this);
  112.         }
  113.         return $this;
  114.     }
  115.     public function removePhoneNumber(PhoneNumber $phoneNumber): static
  116.     {
  117.         if ($this->phoneNumbers->removeElement($phoneNumber)) {
  118.             // set the owning side to null (unless already changed)
  119.             if ($phoneNumber->getUser() === $this) {
  120.                 $phoneNumber->setUser(null);
  121.             }
  122.         }
  123.         return $this;
  124.     }
  125.     /**
  126.      * @return Collection<int, Order>
  127.      */
  128.     public function getOrders(): Collection
  129.     {
  130.         return $this->orders;
  131.     }
  132.     public function addOrder(Order $order): static
  133.     {
  134.         if (!$this->orders->contains($order)) {
  135.             $this->orders->add($order);
  136.             $order->setUser($this);
  137.         }
  138.         return $this;
  139.     }
  140.     public function removeOrder(Order $order): static
  141.     {
  142.         if ($this->orders->removeElement($order)) {
  143.             // set the owning side to null (unless already changed)
  144.             if ($order->getUser() === $this) {
  145.                 $order->setUser(null);
  146.             }
  147.         }
  148.         return $this;
  149.     }
  150.     public function getFirstName(): ?string
  151.     {
  152.         return $this->firstName;
  153.     }
  154.     public function setFirstName(?string $firstName): static
  155.     {
  156.         $this->firstName $firstName;
  157.         return $this;
  158.     }
  159.     public function getMiddleName(): ?string
  160.     {
  161.         return $this->middleName;
  162.     }
  163.     public function setMiddleName(?string $middleName): static
  164.     {
  165.         $this->middleName $middleName;
  166.         return $this;
  167.     }
  168.     public function getLastName(): ?string
  169.     {
  170.         return $this->lastName;
  171.     }
  172.     public function setLastName(?string $lastName): static
  173.     {
  174.         $this->lastName $lastName;
  175.         return $this;
  176.     }
  177.     public function getVerifyCode(): ?string
  178.     {
  179.         return $this->verifyCode;
  180.     }
  181.     public function setVerifyCode(?string $verifyCode): static
  182.     {
  183.         $this->verifyCode $verifyCode;
  184.         return $this;
  185.     }
  186.     public function getEmailVerifiedAt(): ?\DateTimeInterface
  187.     {
  188.         return $this->emailVerifiedAt;
  189.     }
  190.     public function setEmailVerifiedAt(?\DateTimeInterface $emailVerifiedAt): static
  191.     {
  192.         $this->emailVerifiedAt $emailVerifiedAt;
  193.         return $this;
  194.     }
  195.     public function getCodeSentAt(): ?\DateTimeInterface
  196.     {
  197.         return $this->codeSentAt;
  198.     }
  199.     public function setCodeSentAt(?\DateTimeInterface $codeSentAt): static
  200.     {
  201.         $this->codeSentAt $codeSentAt;
  202.         return $this;
  203.     }
  204.     public function getResetHash(): ?string
  205.     {
  206.         return $this->resetHash;
  207.     }
  208.     public function setResetHash(?string $resetHash): static
  209.     {
  210.         $this->resetHash $resetHash;
  211.         return $this;
  212.     }
  213.     /**
  214.      * @return Collection<int, PhoneNumber>
  215.      */
  216.     public function getLockedPhones(): Collection
  217.     {
  218.         return $this->lockedPhones;
  219.     }
  220.     public function addLockedPhone(PhoneNumber $lockedPhone): static
  221.     {
  222.         if (!$this->lockedPhones->contains($lockedPhone)) {
  223.             $this->lockedPhones->add($lockedPhone);
  224.             $lockedPhone->setLockedUser($this);
  225.         }
  226.         return $this;
  227.     }
  228.     public function removeLockedPhone(PhoneNumber $lockedPhone): static
  229.     {
  230.         if ($this->lockedPhones->removeElement($lockedPhone)) {
  231.             // set the owning side to null (unless already changed)
  232.             if ($lockedPhone->getLockedUser() === $this) {
  233.                 $lockedPhone->setLockedUser(null);
  234.             }
  235.         }
  236.         return $this;
  237.     }
  238.     public function getNumberHash(): ?string
  239.     {
  240.         return $this->numberHash;
  241.     }
  242.     public function setNumberHash(?string $numberHash): static
  243.     {
  244.         $this->numberHash $numberHash;
  245.         return $this;
  246.     }
  247.     public function getGeneratePhoneHashAt(): ?\DateTimeInterface
  248.     {
  249.         return $this->generatePhoneHashAt;
  250.     }
  251.     public function setGeneratePhoneHashAt(?\DateTimeInterface $generatePhoneHashAt): static
  252.     {
  253.         $this->generatePhoneHashAt $generatePhoneHashAt;
  254.         return $this;
  255.     }
  256.     public function getMetaTags(): ?string
  257.     {
  258.         return $this->metaTags;
  259.     }
  260.     public function setMetaTags(?string $metaTags): static
  261.     {
  262.         $this->metaTags $metaTags;
  263.         return $this;
  264.     }
  265.     public function getEnabledLabel(): string
  266.     {
  267.         return $this->isEnabled() ? ActiveConstants::LABEL_YES ActiveConstants::LABEL_NO;
  268.     }
  269. }