src/Entity/UserToken.php line 16

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use ApiPlatform\Metadata\ApiResource;
  4. use App\Repository\UserTokenRepository;
  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. #[ORM\Entity(repositoryClassUserTokenRepository::class)]
  10. #[ApiResource]
  11. #[ORM\HasLifecycleCallbacks]
  12. class UserToken
  13. {
  14.     #[ORM\Id]
  15.     #[ORM\GeneratedValue]
  16.     #[ORM\Column]
  17.     private ?int $id null;
  18.     #[ORM\ManyToOne(inversedBy'userTokens')]
  19.     private ?User $users null;
  20.     #[ORM\Column(length255nullabletrue)]
  21.     private ?string $device_id null;
  22.     #[ORM\Column(length255nullabletrue)]
  23.     private ?string $token_fcm null;
  24.     #[ORM\Column(nullabletrue)]
  25.     private ?bool $active null;
  26.     #[ORM\Column(typeTypes::DATETIME_MUTABLEnullabletrue)]
  27.     private ?\DateTimeInterface $lastActiveDate null;
  28.     #[ORM\Column(typeTypes::DATETIME_MUTABLEnullabletrue)]
  29.     private ?\DateTimeInterface $dateEntered null;
  30.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  31.     private ?string $errorDescription null;
  32.     #[ORM\Column(typeTypes::DATETIME_MUTABLEnullabletrue)]
  33.     private ?\DateTimeInterface $dateModified null;
  34.     #[ORM\OneToMany(mappedBy'token'targetEntityNotificationTokens::class)]
  35.     private Collection $notificationTokens;
  36.     public function __construct()
  37.     {
  38.         $this->notificationTokens = new ArrayCollection();
  39.     }
  40.     public function getId(): ?int
  41.     {
  42.         return $this->id;
  43.     }
  44.     public function getUsers(): ?User
  45.     {
  46.         return $this->users;
  47.     }
  48.     public function setUsers(?User $users): static
  49.     {
  50.         $this->users $users;
  51.         return $this;
  52.     }
  53.     public function getDeviceId(): ?string
  54.     {
  55.         return $this->device_id;
  56.     }
  57.     public function setDeviceId(?string $device_id): static
  58.     {
  59.         $this->device_id $device_id;
  60.         return $this;
  61.     }
  62.     public function getTokenFcm(): ?string
  63.     {
  64.         return $this->token_fcm;
  65.     }
  66.     public function setTokenFcm(?string $token_fcm): static
  67.     {
  68.         $this->token_fcm $token_fcm;
  69.         return $this;
  70.     }
  71.     public function isActive(): ?bool
  72.     {
  73.         return $this->active;
  74.     }
  75.     public function setActive(?bool $active): static
  76.     {
  77.         $this->active $active;
  78.         return $this;
  79.     }
  80.     public function getLastActiveDate(): ?\DateTimeInterface
  81.     {
  82.         return $this->lastActiveDate;
  83.     }
  84.     public function setLastActiveDate(?\DateTimeInterface $lastActiveDate): static
  85.     {
  86.         $this->lastActiveDate $lastActiveDate;
  87.         return $this;
  88.     }
  89.     public function getDateEntered(): ?\DateTimeInterface
  90.     {
  91.         return $this->dateEntered;
  92.     }
  93.     public function setDateEntered(?\DateTimeInterface $dateEntered): static
  94.     {
  95.         $this->dateEntered $dateEntered;
  96.         return $this;
  97.     }
  98.     #[ORM\PrePersist]
  99.     public function setCreatedAtValue(): void
  100.     {
  101.         $this->dateEntered = new \DateTime();
  102.     }
  103.     #[ORM\PreUpdate]
  104.     public function setUpdatedAtValue(): void
  105.     {
  106.         $this->lastActiveDate = new \DateTime();
  107.     }
  108.     public function getErrorDescription(): ?string
  109.     {
  110.         return $this->errorDescription;
  111.     }
  112.     public function setErrorDescription(?string $errorDescription): static
  113.     {
  114.         $this->errorDescription $errorDescription;
  115.         return $this;
  116.     }
  117.     public function getDateModified(): ?\DateTimeInterface
  118.     {
  119.         return $this->dateModified;
  120.     }
  121.     public function setDateModified(?\DateTimeInterface $dateModified): static
  122.     {
  123.         $this->dateModified $dateModified;
  124.         return $this;
  125.     }
  126.     /**
  127.      * @return Collection<int, NotificationTokens>
  128.      */
  129.     public function getNotificationTokens(): Collection
  130.     {
  131.         return $this->notificationTokens;
  132.     }
  133.     public function addNotificationToken(NotificationTokens $notificationToken): static
  134.     {
  135.         if (!$this->notificationTokens->contains($notificationToken)) {
  136.             $this->notificationTokens->add($notificationToken);
  137.             $notificationToken->setToken($this);
  138.         }
  139.         return $this;
  140.     }
  141.     public function removeNotificationToken(NotificationTokens $notificationToken): static
  142.     {
  143.         if ($this->notificationTokens->removeElement($notificationToken)) {
  144.             // set the owning side to null (unless already changed)
  145.             if ($notificationToken->getToken() === $this) {
  146.                 $notificationToken->setToken(null);
  147.             }
  148.         }
  149.         return $this;
  150.     }
  151. }