<?php
namespace App\Entity;
use App\Repository\NotificationRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
use Knp\DoctrineBehaviors\Contract\Entity\TimestampableInterface;
use Knp\DoctrineBehaviors\Model\Timestampable\TimestampableTrait;
#[ORM\Entity(repositoryClass: NotificationRepository::class)]
class Notification implements TimestampableInterface
{
use TimestampableTrait;
public CONST STATUS_ARRAY = [
'NEW' => 0,
'VIEWED' => 1,
];
public CONST TYPE_ARRAY = [
'ADD' => 0,
'EDIT' => 1,
'DELETE' => 2,
'UPLOAD' => 3,
];
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
private $id;
#[ORM\Column(type: 'string', length: 255)]
private $title;
#[ORM\Column(type: 'string', length: 255)]
private $message;
#[ORM\Column(type: 'integer')]
private $type;
#[ORM\Column(type: 'string', length: 2000, nullable: true)]
private $link;
#[ORM\Column(type: 'integer')]
private $status;
#[ORM\ManyToOne(inversedBy: 'notifications')]
private ?User $user = null;
public function __construct()
{
$this->target = new ArrayCollection();
}
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 getType(): ?int
{
return strtolower(array_search( $this->type, self::TYPE_ARRAY ));
}
public function setType(string $type): self
{
$this->type = self::TYPE_ARRAY[ strtoupper( $type ) ];
return $this;
}
public function getLink(): ?string
{
return $this->link;
}
public function setLink(?string $link): self
{
$this->link = $link;
return $this;
}
public function getStatus(): ?string
{
return strtolower(array_search( $this->status, self::STATUS_ARRAY ));
}
public function setStatus(string $status): self
{
$this->status = self::STATUS_ARRAY[ strtoupper( $status ) ];
return $this;
}
public function getUser(): ?User
{
return $this->user;
}
public function setUser(?User $user): self
{
$this->user = $user;
return $this;
}
}