<?phpnamespace App\Entity;use ApiPlatform\Metadata\ApiResource;use App\Repository\UserTokenRepository;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use Doctrine\DBAL\Types\Types;use Doctrine\ORM\Mapping as ORM;#[ORM\Entity(repositoryClass: UserTokenRepository::class)]#[ApiResource]#[ORM\HasLifecycleCallbacks]class UserToken{ #[ORM\Id] #[ORM\GeneratedValue] #[ORM\Column] private ?int $id = null; #[ORM\ManyToOne(inversedBy: 'userTokens')] private ?User $users = null; #[ORM\Column(length: 255, nullable: true)] private ?string $device_id = null; #[ORM\Column(length: 255, nullable: true)] private ?string $token_fcm = null; #[ORM\Column(nullable: true)] private ?bool $active = null; #[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: true)] private ?\DateTimeInterface $lastActiveDate = null; #[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: true)] private ?\DateTimeInterface $dateEntered = null; #[ORM\Column(type: Types::TEXT, nullable: true)] private ?string $errorDescription = null; #[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: true)] private ?\DateTimeInterface $dateModified = null; #[ORM\OneToMany(mappedBy: 'token', targetEntity: NotificationTokens::class)] private Collection $notificationTokens; public function __construct() { $this->notificationTokens = new ArrayCollection(); } public function getId(): ?int { return $this->id; } public function getUsers(): ?User { return $this->users; } public function setUsers(?User $users): static { $this->users = $users; return $this; } public function getDeviceId(): ?string { return $this->device_id; } public function setDeviceId(?string $device_id): static { $this->device_id = $device_id; return $this; } public function getTokenFcm(): ?string { return $this->token_fcm; } public function setTokenFcm(?string $token_fcm): static { $this->token_fcm = $token_fcm; return $this; } public function isActive(): ?bool { return $this->active; } public function setActive(?bool $active): static { $this->active = $active; return $this; } public function getLastActiveDate(): ?\DateTimeInterface { return $this->lastActiveDate; } public function setLastActiveDate(?\DateTimeInterface $lastActiveDate): static { $this->lastActiveDate = $lastActiveDate; return $this; } public function getDateEntered(): ?\DateTimeInterface { return $this->dateEntered; } public function setDateEntered(?\DateTimeInterface $dateEntered): static { $this->dateEntered = $dateEntered; return $this; } #[ORM\PrePersist] public function setCreatedAtValue(): void { $this->dateEntered = new \DateTime(); } #[ORM\PreUpdate] public function setUpdatedAtValue(): void { $this->lastActiveDate = new \DateTime(); } public function getErrorDescription(): ?string { return $this->errorDescription; } public function setErrorDescription(?string $errorDescription): static { $this->errorDescription = $errorDescription; return $this; } public function getDateModified(): ?\DateTimeInterface { return $this->dateModified; } public function setDateModified(?\DateTimeInterface $dateModified): static { $this->dateModified = $dateModified; return $this; } /** * @return Collection<int, NotificationTokens> */ public function getNotificationTokens(): Collection { return $this->notificationTokens; } public function addNotificationToken(NotificationTokens $notificationToken): static { if (!$this->notificationTokens->contains($notificationToken)) { $this->notificationTokens->add($notificationToken); $notificationToken->setToken($this); } return $this; } public function removeNotificationToken(NotificationTokens $notificationToken): static { if ($this->notificationTokens->removeElement($notificationToken)) { // set the owning side to null (unless already changed) if ($notificationToken->getToken() === $this) { $notificationToken->setToken(null); } } return $this; }}