<?php
namespace App\Entity;
use App\Repository\ContactRepository;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: ContactRepository::class)]
class Contact
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
private $id;
#[ORM\Column(type: 'string', length: 255)]
private $name;
#[ORM\Column(type: 'string', length: 255)]
private $email;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private $phone;
#[ORM\Column(type: 'string', length: 255)]
private $message;
#[ORM\Column(nullable: true)]
private ?bool $privacyPolicy = null;
#[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: true)]
private ?\DateTimeInterface $createdAt = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $type = null;
const TYPE_FORMCONTACT = 1 ;
const TYPE_DEVIS = 2 ;
const TYPE_CATALOGUE = 3 ;
public function getId(): ?int
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
public function getEmail(): ?string
{
return $this->email;
}
public function setEmail(string $email): self
{
$this->email = $email;
return $this;
}
public function getPhone(): ?string
{
return $this->phone;
}
public function setPhone(?string $phone): self
{
$this->phone = $phone;
return $this;
}
public function getMessage(): ?string
{
return $this->message;
}
public function setMessage(string $message): self
{
$this->message = $message;
return $this;
}
public function toArray(): array {
return [
'name' => $this->getName(),
'email' => $this->getEmail(),
'message' => $this->getMessage(),
'phone' => $this->getPhone(),
'type' => $this->getTypeText(),
];
}
public function isPrivacyPolicy(): ?bool
{
return $this->privacyPolicy;
}
public function setPrivacyPolicy(?bool $privacyPolicy): static
{
$this->privacyPolicy = $privacyPolicy;
return $this;
}
public function getCreatedAt(): ?\DateTimeInterface
{
return $this->createdAt;
}
public function setCreatedAt(?\DateTimeInterface $createdAt): static
{
$this->createdAt = $createdAt;
return $this;
}
public function getType(): ?string
{
return $this->type;
}
public function setType(?string $type): static
{
$this->type = $type;
return $this;
}
public function getTypeText(){
if($this->getType() == '') return '';
return $this->getTypes()[$this->getType()];
}
public static function getTypesChoice(){
return array_flip([
self::TYPE_FORMCONTACT => 'Formulaire contact',
self::TYPE_DEVIS => 'Devis',
self::TYPE_CATALOGUE => 'Catalogue'
]);
}
public static function getTypes(){
return ([
self::TYPE_FORMCONTACT => 'Formulaire contact',
self::TYPE_DEVIS => 'Devis',
self::TYPE_CATALOGUE => 'Catalogue'
]);
}
}