<?php
namespace App\Entity;
use App\Enum\TodoNotificationTypeEnum;
use Doctrine\ORM\Mapping as ORM;
/**
* Todo Board durum değişikliği bildirimi.
*
* Bir SUPER_ADMIN bir todo'nun durumunu değiştirdiğinde (kabul/başlandı/bitti/
* reddedildi) todo sahibine bir bildirim kaydı açılır. Kullanıcı online'sa anında
* (socket), değilse bir sonraki login'inde Dialog ile gösterilir; gösterildikten
* sonra `seen=true` işaretlenir.
*
* @ORM\Entity
* @ORM\Table(name="todo_notifications")
* @ORM\HasLifecycleCallbacks
*/
class TodoNotification
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* Bildirimin gideceği kullanıcı (todo sahibi).
*
* @ORM\ManyToOne(targetEntity=User::class)
* @ORM\JoinColumn(nullable=false, onDelete="CASCADE")
*/
private $user;
/**
* İlgili todo. Todo silinirse bildirim de düşer.
*
* @ORM\ManyToOne(targetEntity=Todos::class)
* @ORM\JoinColumn(nullable=true, onDelete="CASCADE")
*/
private $todo;
/**
* Snapshot: bildirim anındaki todo başlığı (todo değişse/silinse de gösterilebilsin).
*
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $todo_title;
/**
* Bildirim türü: 'status' (durum değişikliği) | 'comment' (yeni yorum).
*
* @ORM\Column(type="todo_notification_type", options={"default": "status"})
*/
private $type = TodoNotificationTypeEnum::STATUS;
/**
* Yeni durum: pending | accepted | in_process | completed | rejected.
* Yorum bildirimlerinde (type=comment) null.dur. DB: todo_status_type ENUM.
*
* @ORM\Column(type="todo_status_type", nullable=true)
*/
private $status;
/**
* type='comment' ise ilgili TodoComment id'si (snapshot referans).
*
* @ORM\Column(type="integer", nullable=true)
*/
private $comment_id;
/**
* Snapshot: yönetici notu / reddetme gerekçesi (HTML olabilir).
*
* @ORM\Column(type="text", nullable=true)
*/
private $note;
/**
* @ORM\Column(type="boolean", options={"default": false})
*/
private $seen = false;
/**
* @ORM\Column(type="datetime")
*/
private $created_at;
/**
* @ORM\PrePersist
*/
public function onPrePersist(): void
{
$this->created_at = new \DateTime();
}
public function getId(): ?int { return $this->id; }
public function getUser(): ?User { return $this->user; }
public function setUser(?User $user): self { $this->user = $user; return $this; }
public function getTodo(): ?Todos { return $this->todo; }
public function setTodo(?Todos $todo): self { $this->todo = $todo; return $this; }
public function getTodoTitle(): ?string { return $this->todo_title; }
public function setTodoTitle(?string $todo_title): self { $this->todo_title = $todo_title; return $this; }
public function getType(): string { return $this->type ?? TodoNotificationTypeEnum::STATUS; }
public function setType(string $type): self { $this->type = $type; return $this; }
public function getStatus(): ?string { return $this->status; }
public function setStatus(?string $status): self { $this->status = $status; return $this; }
public function getCommentId(): ?int { return $this->comment_id; }
public function setCommentId(?int $comment_id): self { $this->comment_id = $comment_id; return $this; }
public function getNote(): ?string { return $this->note; }
public function setNote(?string $note): self { $this->note = $note; return $this; }
public function isSeen(): bool { return (bool) $this->seen; }
public function setSeen(bool $seen): self { $this->seen = $seen; return $this; }
public function getCreatedAt(): ?\DateTime { return $this->created_at; }
}