src/Entity/Notification.php line 12

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\NotificationRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Knp\DoctrineBehaviors\Contract\Entity\TimestampableInterface;
  7. use Knp\DoctrineBehaviors\Model\Timestampable\TimestampableTrait;
  8. #[ORM\Entity(repositoryClassNotificationRepository::class)]
  9. class Notification implements TimestampableInterface
  10. {
  11.     use TimestampableTrait;
  12.     public CONST STATUS_ARRAY = [
  13.         'NEW' => 0,
  14.         'VIEWED' => 1,
  15.     ];
  16.     public CONST TYPE_ARRAY = [
  17.         'ADD' => 0,
  18.         'EDIT' => 1,
  19.         'DELETE' => 2,
  20.         'UPLOAD' => 3,
  21.     ];
  22.     #[ORM\Id]
  23.     #[ORM\GeneratedValue]
  24.     #[ORM\Column(type'integer')]
  25.     private $id;
  26.     #[ORM\Column(type'string'length255)]
  27.     private $title;
  28.     #[ORM\Column(type'string'length255)]
  29.     private $message;
  30.     #[ORM\Column(type'integer')]
  31.     private $type;
  32.     #[ORM\Column(type'string'length2000nullabletrue)]
  33.     private $link;
  34.     #[ORM\Column(type'integer')]
  35.     private $status;
  36.     #[ORM\ManyToOne(inversedBy'notifications')]
  37.     private ?User $user null;
  38.     public function __construct()
  39.     {
  40.         $this->target = new ArrayCollection();
  41.     }
  42.     public function getId(): ?int
  43.     {
  44.         return $this->id;
  45.     }
  46.     public function getTitle(): ?string
  47.     {
  48.         return $this->title;
  49.     }
  50.     public function setTitle(string $title): self
  51.     {
  52.         $this->title $title;
  53.         return $this;
  54.     }
  55.     public function getMessage(): ?string
  56.     {
  57.         return $this->message;
  58.     }
  59.     public function setMessage(string $message): self
  60.     {
  61.         $this->message $message;
  62.         return $this;
  63.     }
  64.     public function getType(): ?int
  65.     {
  66.         return strtolower(array_search$this->typeself::TYPE_ARRAY ));
  67.     }
  68.     public function setType(string $type): self
  69.     {
  70.         $this->type self::TYPE_ARRAYstrtoupper$type ) ];
  71.         return $this;
  72.     }
  73.     public function getLink(): ?string
  74.     {
  75.         return $this->link;
  76.     }
  77.     public function setLink(?string $link): self
  78.     {
  79.         $this->link $link;
  80.         return $this;
  81.     }
  82.     public function getStatus(): ?string
  83.     {
  84.         return strtolower(array_search$this->statusself::STATUS_ARRAY ));
  85.     }
  86.     public function setStatus(string $status): self
  87.     {
  88.         $this->status self::STATUS_ARRAYstrtoupper$status ) ];
  89.         return $this;
  90.     }
  91.     public function getUser(): ?User
  92.     {
  93.         return $this->user;
  94.     }
  95.     public function setUser(?User $user): self
  96.     {
  97.         $this->user $user;
  98.         return $this;
  99.     }
  100. }