src/Entity/Contact.php line 17

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\ContactRepository;
  4. use Cofondateur\SocleTechniqueBundle\Annotation\CrudField;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  9. use Symfony\Component\Validator\Constraints as Assert;
  10. use App\Form\ContactFileFormType;
  11. /**
  12.  * @ORM\Entity(repositoryClass=ContactRepository::class)
  13.  */
  14. class Contact
  15. {
  16.         
  17.     /**
  18.      * @ORM\Id
  19.      * @ORM\GeneratedValue
  20.      * @ORM\Column(type="integer")
  21.      */
  22.     private $id;
  23.     /**
  24.      * @Assert\NotBlank
  25.      * @ORM\Column(type="string", length=255)
  26.      * @CrudField(label="Prénom", index=true)
  27.      */
  28.     private $firstname;
  29.     /**
  30.      * @Assert\NotBlank
  31.      * @ORM\Column(type="string", length=255)
  32.      * @CrudField(label="Nom", index=true)
  33.      */
  34.     private $lastname;
  35.     /**
  36.      * @Assert\NotBlank
  37.      * @ORM\Column(type="string", length=255)
  38.      * @CrudField(label="Objet", index=true)
  39.      */
  40.     private $subject;
  41.     /**
  42.      * @Assert\NotBlank
  43.      * @ORM\Column(type="text")
  44.      * @CrudField(label="Message")
  45.      */
  46.     private $message;
  47.     /**
  48.      * @Assert\NotBlank
  49.      * @ORM\Column(type="string", length=255)
  50.      * @CrudField(label="Numéro de téléphone")
  51.      */
  52.     private $phoneNumber;
  53.     /**
  54.      * @Assert\Email()
  55.      * @Assert\NotBlank
  56.      * @ORM\Column(type="string", length=255)
  57.      * @CrudField(label="Email")
  58.      */
  59.     private $email;
  60.     /**
  61.      * @ORM\OneToMany(targetEntity=ContactFile::class, mappedBy="contact", cascade={"persist", "remove"})
  62.      */
  63.     private $contactFiles;
  64.     /**
  65.      * @ORM\Column(type="datetime")
  66.      * @CrudField(label="Date", index=true)
  67.      */
  68.     private $createdAt;
  69.     public function __construct()
  70.     {
  71.         $this->contactFiles = new ArrayCollection();
  72.     }
  73.     public function __toString(): string
  74.     {
  75.         return $this->getId() ?? "N/A";
  76.     }
  77.     public function getId(): ?int
  78.     {
  79.         return $this->id;
  80.     }
  81.     public function getFirstname(): ?string
  82.     {
  83.         return $this->firstname;
  84.     }
  85.     public function setFirstname(?string $firstname): self
  86.     {
  87.         $this->firstname $firstname;
  88.         return $this;
  89.     }
  90.     public function getLastname(): ?string
  91.     {
  92.         return $this->lastname;
  93.     }
  94.     public function setLastname(?string $lastname): self
  95.     {
  96.         $this->lastname $lastname;
  97.         return $this;
  98.     }
  99.     public function getSubject(): ?string
  100.     {
  101.         return $this->subject;
  102.     }
  103.     public function setSubject(?string $subject): self
  104.     {
  105.         $this->subject $subject;
  106.         return $this;
  107.     }
  108.     public function getMessage(): ?string
  109.     {
  110.         return $this->message;
  111.     }
  112.     public function setMessage(?string $message): self
  113.     {
  114.         $this->message $message;
  115.         return $this;
  116.     }
  117.     public function getPhoneNumber(): ?string
  118.     {
  119.         return $this->phoneNumber;
  120.     }
  121.     public function setPhoneNumber(?string $phoneNumber): self
  122.     {
  123.         $this->phoneNumber $phoneNumber;
  124.         return $this;
  125.     }
  126.     /**
  127.      * @return Collection|ContactFile[]
  128.      */
  129.     public function getContactFiles(): Collection
  130.     {
  131.         return $this->contactFiles;
  132.     }
  133.     public function addContactFile(ContactFile $contactFile): self
  134.     {
  135.         if (!$this->contactFiles->contains($contactFile)) {
  136.             $this->contactFiles[] = $contactFile;
  137.             $contactFile->setContact($this);
  138.         }
  139.         return $this;
  140.     }
  141.     public function removeContactFile(ContactFile $contactFile): self
  142.     {
  143.         if ($this->contactFiles->removeElement($contactFile)) {
  144.             // set the owning side to null (unless already changed)
  145.             if ($contactFile->getContact() === $this) {
  146.                 $contactFile->setContact(null);
  147.             }
  148.         }
  149.         return $this;
  150.     }
  151.     public function getEmail(): ?string
  152.     {
  153.         return $this->email;
  154.     }
  155.     public function setEmail(?string $email): self
  156.     {
  157.         $this->email $email;
  158.         return $this;
  159.     }
  160.     public function getCreatedAt(): ?\DateTimeInterface
  161.     {
  162.         return $this->createdAt;
  163.     }
  164.     public function setCreatedAt(\DateTimeInterface $createdAt): self
  165.     {
  166.         $this->createdAt $createdAt;
  167.         return $this;
  168.     }
  169. }