src/Entity/Contact.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Entity\Traits\TimestampableTrait;
  4. use App\Repository\ContactRepository;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Symfony\Component\Validator\Constraints as Assert;
  7. #[ORM\HasLifecycleCallbacks]
  8. #[ORM\Entity(repositoryClass: ContactRepository::class)]
  9. #[ORM\Table(name: 'contact')]
  10. class Contact
  11. {
  12.     use TimestampableTrait;
  13.     #[ORM\Column(name: 'id', type: 'integer')]
  14.     #[ORM\Id]
  15.     #[ORM\GeneratedValue(strategy: 'AUTO')]
  16.     private ?int $id = null;
  17.     #[ORM\Column(name: 'email', type: 'string', length: 50)]
  18.     #[Assert\NotBlank(message: "L'adresse email est obligatoire.")]
  19.     #[Assert\Email(message: "L'email est incorrect.")]
  20.     private ?string $email = null;
  21.     #[Assert\NotBlank(message: 'Le numéro de téléphone est obligatoire.')]
  22.     #[ORM\Column(name: 'phone', type: 'string', length: 255, nullable: true)]
  23.     protected ?string $phone = null;
  24.     #[ORM\Column(name: 'object', type: 'string', length: 255)]
  25.     #[Assert\NotBlank(message: "L'objet est obligatoire.")]
  26.     #[Assert\Length(max: 255, exactMessage: 'Le nombre de caractères est trop important.')]
  27.     private ?string $object = null;
  28.     #[ORM\Column(name: 'message', type: 'text')]
  29.     #[Assert\NotBlank(message: 'Le message est obligatoire.')]
  30.     private ?string $message = null;
  31.     #[ORM\PrePersist]
  32.     #[ORM\PreUpdate]
  33.     public function updatedTimestamps(): void
  34.     {
  35.         $dateTimeNow = new \DateTime();
  36.         if (null === $this->getCreatedAt()) {
  37.             $this->setCreatedAt($dateTimeNow);
  38.         }
  39.     }
  40.     public function getId(): ?int
  41.     {
  42.         return $this->id;
  43.     }
  44.     public function setEmail(?string $email): static
  45.     {
  46.         $this->email = $email;
  47.         return $this;
  48.     }
  49.     public function getEmail(): ?string
  50.     {
  51.         return $this->email;
  52.     }
  53.     public function getPhone(): ?string
  54.     {
  55.         return $this->phone;
  56.     }
  57.     public function setPhone(string $phone): static
  58.     {
  59.         $this->phone = $phone;
  60.         return $this;
  61.     }
  62.     public function setObject(?string $object): static
  63.     {
  64.         $this->object = $object;
  65.         return $this;
  66.     }
  67.     public function getObject(): ?string
  68.     {
  69.         return $this->object;
  70.     }
  71.     public function setMessage(?string $message): static
  72.     {
  73.         $this->message = $message;
  74.         return $this;
  75.     }
  76.     public function getMessage(): ?string
  77.     {
  78.         return $this->message;
  79.     }
  80. }