<?phpnamespace App\Entity;use App\Repository\AlerteUtilisateurRepository;use Doctrine\ORM\Mapping as ORM;#[ORM\Entity(repositoryClass: AlerteUtilisateurRepository::class)]#[ORM\Table(name: 'alerte_utilisateur')]#[ORM\Index(name: 'idx_alerte_user', columns: ['alerte_id', 'user_id'])]#[ORM\Index(name: 'idx_user_statut', columns: ['user_id', 'statut'])]class AlerteUtilisateur{ #[ORM\Id] #[ORM\GeneratedValue] #[ORM\Column] private ?int $id = null; #[ORM\ManyToOne(targetEntity: Alert::class)] #[ORM\JoinColumn(nullable: false, onDelete: 'CASCADE')] private ?Alert $alerte = null; #[ORM\ManyToOne(targetEntity: User::class)] #[ORM\JoinColumn(nullable: false, onDelete: 'CASCADE')] private ?User $user = null; #[ORM\Column(length: 20)] private ?string $statut = 'nouvelle'; // nouvelle, vue, traitee, ignoree #[ORM\Column] private ?\DateTimeImmutable $createdAt = null; #[ORM\Column(nullable: true)] private ?\DateTimeImmutable $viewedAt = null; #[ORM\Column(nullable: true)] private ?\DateTimeImmutable $treatedAt = null; public function __construct() { $this->createdAt = new \DateTimeImmutable(); $this->statut = 'nouvelle'; } public function getId(): ?int { return $this->id; } public function getAlerte(): ?Alert { return $this->alerte; } public function setAlerte(?Alert $alerte): static { $this->alerte = $alerte; return $this; } public function getUser(): ?User { return $this->user; } public function setUser(?User $user): static { $this->user = $user; return $this; } public function getStatut(): ?string { return $this->statut; } public function setStatut(string $statut): static { $this->statut = $statut; return $this; } public function getCreatedAt(): ?\DateTimeImmutable { return $this->createdAt; } public function setCreatedAt(\DateTimeImmutable $createdAt): static { $this->createdAt = $createdAt; return $this; } public function getViewedAt(): ?\DateTimeImmutable { return $this->viewedAt; } public function setViewedAt(?\DateTimeImmutable $viewedAt): static { $this->viewedAt = $viewedAt; return $this; } public function getTreatedAt(): ?\DateTimeImmutable { return $this->treatedAt; } public function setTreatedAt(?\DateTimeImmutable $treatedAt): static { $this->treatedAt = $treatedAt; return $this; } // Méthodes utilitaires public function isNouvelle(): bool { return $this->statut === 'nouvelle'; } public function marquerCommeVue(): void { if ($this->statut === 'nouvelle') { $this->statut = 'vue'; $this->viewedAt = new \DateTimeImmutable(); } } public function marquerCommeTraitee(): void { $this->statut = 'traitee'; $this->treatedAt = new \DateTimeImmutable(); } public function marquerCommeIgnoree(): void { $this->statut = 'ignoree'; }}