<?php
namespace App\Entity;
use ApiPlatform\Metadata\ApiResource;
use App\Repository\UserTokenRepository;
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;
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();
}
}