161 lines
3.2 KiB
PHP
161 lines
3.2 KiB
PHP
<?php
|
|
|
|
namespace DMD\LaLigaApi\Entity;
|
|
|
|
use DMD\LaLigaApi\Repository\NotificationRepository;
|
|
use Doctrine\ORM\Mapping as ORM;
|
|
|
|
#[ORM\Entity(repositoryClass: NotificationRepository::class)]
|
|
#[ORM\HasLifecycleCallbacks]
|
|
class Notification
|
|
{
|
|
#[ORM\Id]
|
|
#[ORM\GeneratedValue]
|
|
#[ORM\Column]
|
|
private ?int $id = null;
|
|
|
|
#[ORM\Column(length: 255, nullable: true)]
|
|
private ?string $type = null;
|
|
|
|
#[ORM\ManyToOne(inversedBy: 'requestsSent')]
|
|
private ?User $userWhoFiredEvent = null;
|
|
|
|
#[ORM\Column(length: 280, nullable: true)]
|
|
private ?string $message = null;
|
|
|
|
#[ORM\ManyToOne(inversedBy: 'notifications')]
|
|
private ?League $league = null;
|
|
|
|
#[ORM\Column(nullable: true)]
|
|
private ?\DateTimeImmutable $createdAt = null;
|
|
|
|
#[ORM\Column(nullable: true)]
|
|
private ?int $teamId = null;
|
|
|
|
#[ORM\ManyToOne(inversedBy: 'receivedNotifications')]
|
|
#[ORM\JoinColumn(nullable: false)]
|
|
private ?User $userToNotify = null;
|
|
|
|
#[ORM\Column(nullable: true)]
|
|
private ?bool $isRead = null;
|
|
|
|
#[ORM\Column(nullable: true)]
|
|
private ?\DateTimeImmutable $readAt = null;
|
|
|
|
public function getId(): ?int
|
|
{
|
|
return $this->id;
|
|
}
|
|
|
|
public function getType(): ?string
|
|
{
|
|
return $this->type;
|
|
}
|
|
|
|
public function setType(?string $type): static
|
|
{
|
|
$this->type = $type;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getUserWhoFiredEvent(): ?User
|
|
{
|
|
return $this->userWhoFiredEvent;
|
|
}
|
|
|
|
public function setUserWhoFiredEvent(?User $userWhoFiredEvent): static
|
|
{
|
|
$this->userWhoFiredEvent = $userWhoFiredEvent;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getMessage(): ?string
|
|
{
|
|
return $this->message;
|
|
}
|
|
|
|
public function setMessage(?string $message): static
|
|
{
|
|
$this->message = $message;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getLeague(): ?League
|
|
{
|
|
return $this->league;
|
|
}
|
|
|
|
public function setLeague(?League $league): static
|
|
{
|
|
$this->league = $league;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getCreatedAt(): ?\DateTimeImmutable
|
|
{
|
|
return $this->createdAt;
|
|
}
|
|
|
|
/**
|
|
* @throws \Exception
|
|
*/
|
|
#[ORM\PrePersist]
|
|
public function setCreatedAt(): static
|
|
{
|
|
$this->createdAt = new \DateTimeImmutable('now', new \DateTimeZone('Europe/Madrid'));
|
|
return $this;
|
|
}
|
|
|
|
public function getTeamId(): ?int
|
|
{
|
|
return $this->teamId;
|
|
}
|
|
|
|
public function setTeamId(?int $teamId): static
|
|
{
|
|
$this->teamId = $teamId;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getUserToNotify(): ?User
|
|
{
|
|
return $this->userToNotify;
|
|
}
|
|
|
|
public function setUserToNotify(?User $userToNotify): static
|
|
{
|
|
$this->userToNotify = $userToNotify;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function isIsRead(): ?bool
|
|
{
|
|
return $this->isRead;
|
|
}
|
|
|
|
public function setIsRead(?bool $isRead): static
|
|
{
|
|
$this->isRead = $isRead;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getReadAt(): ?\DateTimeImmutable
|
|
{
|
|
return $this->readAt;
|
|
}
|
|
|
|
public function setReadAt(?\DateTimeImmutable $readAt): static
|
|
{
|
|
$this->readAt = $readAt;
|
|
|
|
return $this;
|
|
}
|
|
}
|