142 lines
2.6 KiB
PHP
142 lines
2.6 KiB
PHP
<?php
|
|
|
|
namespace App\Entity;
|
|
|
|
use Doctrine\ORM\Mapping as ORM;
|
|
use Gedmo\Mapping\Annotation as Gedmo;
|
|
use App\Repository\NotificationRepository;
|
|
|
|
/**
|
|
* @ORM\Entity(repositoryClass=NotificationRepository::class)
|
|
*/
|
|
class Notification
|
|
{
|
|
/**
|
|
* @ORM\Id
|
|
* @ORM\GeneratedValue
|
|
* @ORM\Column(type="integer")
|
|
*/
|
|
private $id;
|
|
|
|
/**
|
|
* @ORM\ManyToOne(targetEntity=User::class, inversedBy="notificationsSent")
|
|
*/
|
|
private $sender;
|
|
|
|
/**
|
|
* @ORM\ManyToOne(targetEntity=User::class, inversedBy="notifications")
|
|
* @ORM\JoinColumn(nullable=false)
|
|
*/
|
|
private $receiver;
|
|
|
|
/**
|
|
* @ORM\Column(type="string", length=255)
|
|
*/
|
|
private $icon;
|
|
|
|
/**
|
|
* @ORM\Column(type="text")
|
|
*/
|
|
private $content;
|
|
|
|
/**
|
|
* @ORM\Column(type="datetime_immutable")
|
|
* @Gedmo\Timestampable(on="create")
|
|
*/
|
|
private $createdAt;
|
|
|
|
/**
|
|
* @ORM\Column(type="boolean", options={"default":"0"})
|
|
*/
|
|
private $readed = false;
|
|
|
|
public function __construct(User $Receiver, string $Content, ?User $Sender = null, ?string $Icon = null)
|
|
{
|
|
$this->setReceiver($Receiver);
|
|
$this->setContent($Content);
|
|
if (null != $Sender) {
|
|
$this->setSender($Sender);
|
|
}
|
|
if (null != $Icon) {
|
|
$this->setIcon($Icon);
|
|
}
|
|
}
|
|
|
|
public function getId(): ?int
|
|
{
|
|
return $this->id;
|
|
}
|
|
|
|
public function getSender(): ?User
|
|
{
|
|
return $this->sender;
|
|
}
|
|
|
|
public function setSender(?User $sender): self
|
|
{
|
|
$this->sender = $sender;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getReceiver(): ?User
|
|
{
|
|
return $this->receiver;
|
|
}
|
|
|
|
public function setReceiver(?User $receiver): self
|
|
{
|
|
$this->receiver = $receiver;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getIcon(): ?string
|
|
{
|
|
return $this->icon;
|
|
}
|
|
|
|
public function setIcon(string $icon): self
|
|
{
|
|
$this->icon = $icon;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getContent(): ?string
|
|
{
|
|
return $this->content;
|
|
}
|
|
|
|
public function setContent(string $content): self
|
|
{
|
|
$this->content = $content;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getCreatedAt(): ?\DateTimeImmutable
|
|
{
|
|
return $this->createdAt;
|
|
}
|
|
|
|
public function setCreatedAt(\DateTimeImmutable $createdAt): self
|
|
{
|
|
$this->createdAt = $createdAt;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getReaded(): ?bool
|
|
{
|
|
return $this->readed;
|
|
}
|
|
|
|
public function setReaded(bool $readed): self
|
|
{
|
|
$this->readed = $readed;
|
|
|
|
return $this;
|
|
}
|
|
}
|