src/Entity/TodoNotification.php line 20

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Enum\TodoNotificationTypeEnum;
  4. use Doctrine\ORM\Mapping as ORM;
  5. /**
  6.  * Todo Board durum değişikliği bildirimi.
  7.  *
  8.  * Bir SUPER_ADMIN bir todo'nun durumunu değiştirdiğinde (kabul/başlandı/bitti/
  9.  * reddedildi) todo sahibine bir bildirim kaydı açılır. Kullanıcı online'sa anında
  10.  * (socket), değilse bir sonraki login'inde Dialog ile gösterilir; gösterildikten
  11.  * sonra `seen=true` işaretlenir.
  12.  *
  13.  * @ORM\Entity
  14.  * @ORM\Table(name="todo_notifications")
  15.  * @ORM\HasLifecycleCallbacks
  16.  */
  17. class TodoNotification
  18. {
  19.     /**
  20.      * @ORM\Id
  21.      * @ORM\GeneratedValue
  22.      * @ORM\Column(type="integer")
  23.      */
  24.     private $id;
  25.     /**
  26.      * Bildirimin gideceği kullanıcı (todo sahibi).
  27.      *
  28.      * @ORM\ManyToOne(targetEntity=User::class)
  29.      * @ORM\JoinColumn(nullable=false, onDelete="CASCADE")
  30.      */
  31.     private $user;
  32.     /**
  33.      * İlgili todo. Todo silinirse bildirim de düşer.
  34.      *
  35.      * @ORM\ManyToOne(targetEntity=Todos::class)
  36.      * @ORM\JoinColumn(nullable=true, onDelete="CASCADE")
  37.      */
  38.     private $todo;
  39.     /**
  40.      * Snapshot: bildirim anındaki todo başlığı (todo değişse/silinse de gösterilebilsin).
  41.      *
  42.      * @ORM\Column(type="string", length=255, nullable=true)
  43.      */
  44.     private $todo_title;
  45.     /**
  46.      * Bildirim türü: 'status' (durum değişikliği) | 'comment' (yeni yorum).
  47.      *
  48.      * @ORM\Column(type="todo_notification_type", options={"default": "status"})
  49.      */
  50.     private $type = TodoNotificationTypeEnum::STATUS;
  51.     /**
  52.      * Yeni durum: pending | accepted | in_process | completed | rejected.
  53.      * Yorum bildirimlerinde (type=comment) null.dur. DB: todo_status_type ENUM.
  54.      *
  55.      * @ORM\Column(type="todo_status_type", nullable=true)
  56.      */
  57.     private $status;
  58.     /**
  59.      * type='comment' ise ilgili TodoComment id'si (snapshot referans).
  60.      *
  61.      * @ORM\Column(type="integer", nullable=true)
  62.      */
  63.     private $comment_id;
  64.     /**
  65.      * Snapshot: yönetici notu / reddetme gerekçesi (HTML olabilir).
  66.      *
  67.      * @ORM\Column(type="text", nullable=true)
  68.      */
  69.     private $note;
  70.     /**
  71.      * @ORM\Column(type="boolean", options={"default": false})
  72.      */
  73.     private $seen = false;
  74.     /**
  75.      * @ORM\Column(type="datetime")
  76.      */
  77.     private $created_at;
  78.     /**
  79.      * @ORM\PrePersist
  80.      */
  81.     public function onPrePersist(): void
  82.     {
  83.         $this->created_at = new \DateTime();
  84.     }
  85.     public function getId(): ?int { return $this->id; }
  86.     public function getUser(): ?User { return $this->user; }
  87.     public function setUser(?User $user): self { $this->user = $user; return $this; }
  88.     public function getTodo(): ?Todos { return $this->todo; }
  89.     public function setTodo(?Todos $todo): self { $this->todo = $todo; return $this; }
  90.     public function getTodoTitle(): ?string { return $this->todo_title; }
  91.     public function setTodoTitle(?string $todo_title): self { $this->todo_title = $todo_title; return $this; }
  92.     public function getType(): string { return $this->type ?? TodoNotificationTypeEnum::STATUS; }
  93.     public function setType(string $type): self { $this->type = $type; return $this; }
  94.     public function getStatus(): ?string { return $this->status; }
  95.     public function setStatus(?string $status): self { $this->status = $status; return $this; }
  96.     public function getCommentId(): ?int { return $this->comment_id; }
  97.     public function setCommentId(?int $comment_id): self { $this->comment_id = $comment_id; return $this; }
  98.     public function getNote(): ?string { return $this->note; }
  99.     public function setNote(?string $note): self { $this->note = $note; return $this; }
  100.     public function isSeen(): bool { return (bool) $this->seen; }
  101.     public function setSeen(bool $seen): self { $this->seen = $seen; return $this; }
  102.     public function getCreatedAt(): ?\DateTime { return $this->created_at; }
  103. }