src/Entity/Newsletter.php line 12

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\NewsletterRepository;
  4. use DateTime;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Symfony\Component\Validator\Constraints as Assert;
  7. #[ORM\Entity(repositoryClassNewsletterRepository::class)]
  8. #[ORM\Table(name'newsletter')]
  9. class Newsletter
  10. {
  11.     #[ORM\Column(type'boolean')]
  12.     private bool $isDeleted false;
  13.     #[ORM\Column(name'createdAt'type'datetime')]
  14.     private DateTime $createdAt;
  15.     #[ORM\Id]
  16.     #[ORM\Column(name'id'type'integer')]
  17.     #[ORM\GeneratedValue(strategy'AUTO')]
  18.     private int $id;
  19.     #[Assert\NotBlank(message'Ce champ est obligatoire')]
  20.     #[Assert\Email(
  21.         message"L'adresse email '{{ value }}' n'est pas valide."
  22.     )]
  23.     #[ORM\Column(name'email'type'string'length255)]
  24.     private string $email;
  25.     public function __construct()
  26.     {
  27.         $this->createdAt = new DateTime();
  28.     }
  29.     public function __toString()
  30.     {
  31.         return "#" $this->id " - " $this->email;
  32.     }
  33.     /**
  34.      * Get id
  35.      *
  36.      * @return int
  37.      */
  38.     public function getId()
  39.     {
  40.         return $this->id;
  41.     }
  42.     /**
  43.      * Set email
  44.      *
  45.      * @param string $email
  46.      *
  47.      * @return Newsletter
  48.      */
  49.     public function setEmail($email)
  50.     {
  51.         $this->email $email;
  52.         return $this;
  53.     }
  54.     /**
  55.      * Get email
  56.      *
  57.      * @return string
  58.      */
  59.     public function getEmail()
  60.     {
  61.         return $this->email;
  62.     }
  63.     /**
  64.      * Set createdAt
  65.      *
  66.      * @param DateTime $createdAt
  67.      *
  68.      * @return Newsletter
  69.      */
  70.     public function setCreatedAt($createdAt)
  71.     {
  72.         $this->createdAt $createdAt;
  73.         return $this;
  74.     }
  75.     /**
  76.      * Get createdAt
  77.      *
  78.      * @return DateTime
  79.      */
  80.     public function getCreatedAt()
  81.     {
  82.         return $this->createdAt;
  83.     }
  84.     /**
  85.      * Set isDeleted
  86.      *
  87.      * @param boolean $isDeleted
  88.      *
  89.      * @return Newsletter
  90.      */
  91.     public function setIsDeleted($isDeleted)
  92.     {
  93.         $this->isDeleted $isDeleted;
  94.         return $this;
  95.     }
  96.     /**
  97.      * Get isDeleted
  98.      *
  99.      * @return boolean
  100.      */
  101.     public function getIsDeleted()
  102.     {
  103.         return $this->isDeleted;
  104.     }
  105. }