<?php
namespace App\Entity;
use App\Repository\ContactRepository;
use Cofondateur\SocleTechniqueBundle\Annotation\CrudField;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Vich\UploaderBundle\Mapping\Annotation as Vich;
use Symfony\Component\Validator\Constraints as Assert;
use App\Form\ContactFileFormType;
/**
* @ORM\Entity(repositoryClass=ContactRepository::class)
*/
class Contact
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @Assert\NotBlank
* @ORM\Column(type="string", length=255)
* @CrudField(label="Prénom", index=true)
*/
private $firstname;
/**
* @Assert\NotBlank
* @ORM\Column(type="string", length=255)
* @CrudField(label="Nom", index=true)
*/
private $lastname;
/**
* @Assert\NotBlank
* @ORM\Column(type="string", length=255)
* @CrudField(label="Objet", index=true)
*/
private $subject;
/**
* @Assert\NotBlank
* @ORM\Column(type="text")
* @CrudField(label="Message")
*/
private $message;
/**
* @Assert\NotBlank
* @ORM\Column(type="string", length=255)
* @CrudField(label="Numéro de téléphone")
*/
private $phoneNumber;
/**
* @Assert\Email()
* @Assert\NotBlank
* @ORM\Column(type="string", length=255)
* @CrudField(label="Email")
*/
private $email;
/**
* @ORM\OneToMany(targetEntity=ContactFile::class, mappedBy="contact", cascade={"persist", "remove"})
*/
private $contactFiles;
/**
* @ORM\Column(type="datetime")
* @CrudField(label="Date", index=true)
*/
private $createdAt;
public function __construct()
{
$this->contactFiles = new ArrayCollection();
}
public function __toString(): string
{
return $this->getId() ?? "N/A";
}
public function getId(): ?int
{
return $this->id;
}
public function getFirstname(): ?string
{
return $this->firstname;
}
public function setFirstname(?string $firstname): self
{
$this->firstname = $firstname;
return $this;
}
public function getLastname(): ?string
{
return $this->lastname;
}
public function setLastname(?string $lastname): self
{
$this->lastname = $lastname;
return $this;
}
public function getSubject(): ?string
{
return $this->subject;
}
public function setSubject(?string $subject): self
{
$this->subject = $subject;
return $this;
}
public function getMessage(): ?string
{
return $this->message;
}
public function setMessage(?string $message): self
{
$this->message = $message;
return $this;
}
public function getPhoneNumber(): ?string
{
return $this->phoneNumber;
}
public function setPhoneNumber(?string $phoneNumber): self
{
$this->phoneNumber = $phoneNumber;
return $this;
}
/**
* @return Collection|ContactFile[]
*/
public function getContactFiles(): Collection
{
return $this->contactFiles;
}
public function addContactFile(ContactFile $contactFile): self
{
if (!$this->contactFiles->contains($contactFile)) {
$this->contactFiles[] = $contactFile;
$contactFile->setContact($this);
}
return $this;
}
public function removeContactFile(ContactFile $contactFile): self
{
if ($this->contactFiles->removeElement($contactFile)) {
// set the owning side to null (unless already changed)
if ($contactFile->getContact() === $this) {
$contactFile->setContact(null);
}
}
return $this;
}
public function getEmail(): ?string
{
return $this->email;
}
public function setEmail(?string $email): self
{
$this->email = $email;
return $this;
}
public function getCreatedAt(): ?\DateTimeInterface
{
return $this->createdAt;
}
public function setCreatedAt(\DateTimeInterface $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
}