src/Entity/Notification.php line 12
<?phpnamespace App\Entity;use App\Repository\NotificationRepository;use DateTime;use Doctrine\DBAL\Types\Types;use Doctrine\ORM\Mapping as ORM;use Symfony\Component\Serializer\Annotation\Groups;#[ORM\Entity(repositoryClass: NotificationRepository::class)]class Notification{#[ORM\Id]#[ORM\GeneratedValue]#[ORM\Column]private ?int $id = null;#[ORM\Column(length: 255)]#[Groups('read:notification')]private ?string $title = null;#[ORM\Column(length: 255)]#[Groups('read:notification')]private ?string $message = null;#[ORM\Column(length: 255)]#[Groups('read:notification')]private ?string $url = null;#[ORM\Column(length: 255, nullable: true)]#[Groups('create:notification')]private ?string $channel = 'target';#[ORM\Column(length: 255, nullable: true)]private ?string $target = null;#[ORM\Column(type: Types::DATETIME_MUTABLE)]#[Groups('read:notification')]private ?\DateTimeInterface $createdAt;#[ORM\ManyToOne]private ?User $user = null;public function __construct(){$this->createdAt = new DateTime();}public function getId(): ?int{return $this->id;}public function getTitle(): ?string{return $this->title;}public function setTitle(string $title): self{$this->title = $title;return $this;}public function getMessage(): ?string{return $this->message;}public function setMessage(string $message): self{$this->message = $message;return $this;}public function getUrl(): ?string{return $this->url;}public function setUrl(string $url): self{$this->url = $url;return $this;}public function getChannel(): ?string{return $this->channel;}public function setChannel(?string $channel): self{$this->channel = $channel;return $this;}public function getTarget(): ?string{return $this->target;}public function setTarget(?string $target): self{$this->target = $target;return $this;}public function getCreatedAt(): ?\DateTimeInterface{return $this->createdAt;}public function setCreatedAt(\DateTimeInterface $createdAt): self{$this->createdAt = $createdAt;return $this;}public function getUser(): ?User{return $this->user;}public function setUser(?User $user): self{$this->user = $user;return $this;}public function isRead(): bool{if (null === $this->user) return false;$notificationsReadAt = $this->user->getNotificationsReadAt();return $notificationsReadAt && $this->createdAt > $notificationsReadAt;}}