<?php
namespace App\Entity;
use App\Entity\Traits\TimestampableTrait;
use App\Repository\ContactRepository;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
#[ORM\HasLifecycleCallbacks]
#[ORM\Entity(repositoryClass: ContactRepository::class)]
#[ORM\Table(name: 'contact')]
class Contact
{
use TimestampableTrait;
#[ORM\Column(name: 'id', type: 'integer')]
#[ORM\Id]
#[ORM\GeneratedValue(strategy: 'AUTO')]
private ?int $id = null;
#[ORM\Column(name: 'email', type: 'string', length: 50)]
#[Assert\NotBlank(message: "L'adresse email est obligatoire.")]
#[Assert\Email(message: "L'email est incorrect.")]
private ?string $email = null;
#[Assert\NotBlank(message: 'Le numéro de téléphone est obligatoire.')]
#[ORM\Column(name: 'phone', type: 'string', length: 255, nullable: true)]
protected ?string $phone = null;
#[ORM\Column(name: 'object', type: 'string', length: 255)]
#[Assert\NotBlank(message: "L'objet est obligatoire.")]
#[Assert\Length(max: 255, exactMessage: 'Le nombre de caractères est trop important.')]
private ?string $object = null;
#[ORM\Column(name: 'message', type: 'text')]
#[Assert\NotBlank(message: 'Le message est obligatoire.')]
private ?string $message = null;
#[ORM\PrePersist]
#[ORM\PreUpdate]
public function updatedTimestamps(): void
{
$dateTimeNow = new \DateTime();
if (null === $this->getCreatedAt()) {
$this->setCreatedAt($dateTimeNow);
}
}
public function getId(): ?int
{
return $this->id;
}
public function setEmail(?string $email): static
{
$this->email = $email;
return $this;
}
public function getEmail(): ?string
{
return $this->email;
}
public function getPhone(): ?string
{
return $this->phone;
}
public function setPhone(string $phone): static
{
$this->phone = $phone;
return $this;
}
public function setObject(?string $object): static
{
$this->object = $object;
return $this;
}
public function getObject(): ?string
{
return $this->object;
}
public function setMessage(?string $message): static
{
$this->message = $message;
return $this;
}
public function getMessage(): ?string
{
return $this->message;
}
}