src/Entity/CmsNewsletter.php line 12

  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\CmsNewsletterRepository;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  6. use Symfony\Component\Validator\Constraints as Assert;
  7. #[ORM\Entity(repositoryClassCmsNewsletterRepository::class)]
  8. #[UniqueEntity(fields: ['email'], message"Cet adresse email est déjà abonné au newsletter")]
  9. class CmsNewsletter
  10. {
  11.     #[ORM\Id]
  12.     #[ORM\GeneratedValue]
  13.     #[ORM\Column]
  14.     private ?int $id null;
  15.     #[Assert\Email]
  16.     #[ORM\Column(length255uniquetrue)]
  17.     private ?string $email null;
  18.     #[ORM\Column]
  19.     private ?\DateTimeImmutable $createdAt null;
  20.     #[ORM\Column]
  21.     private ?\DateTimeImmutable $updatedAt;
  22.     public function __construct()
  23.     {
  24.         if (!$this->createdAt)
  25.             $this->createdAt = new \DateTimeImmutable();
  26.         $this->updatedAt = new \DateTimeImmutable();
  27.     }
  28.     public function getId(): ?int
  29.     {
  30.         return $this->id;
  31.     }
  32.     public function getEmail(): ?string
  33.     {
  34.         return $this->email;
  35.     }
  36.     public function setEmail(string $email): self
  37.     {
  38.         $this->email $email;
  39.         return $this;
  40.     }
  41.     public function getCreatedAt(): ?\DateTimeImmutable
  42.     {
  43.         return $this->createdAt;
  44.     }
  45.     public function setCreatedAt(\DateTimeImmutable $createdAt): self
  46.     {
  47.         $this->createdAt $createdAt;
  48.         return $this;
  49.     }
  50.     public function getUpdatedAt(): ?\DateTimeImmutable
  51.     {
  52.         return $this->updatedAt;
  53.     }
  54.     public function setUpdatedAt(\DateTimeImmutable $updatedAt): self
  55.     {
  56.         $this->updatedAt $updatedAt;
  57.         return $this;
  58.     }
  59. }