src/Entity/Contact.php line 15

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\ContactRepository;
  4. use App\Validator\PhoneNumber;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Symfony\Component\Validator\Constraints as Assert;
  9. /**
  10.  * @ORM\Entity(repositoryClass=ContactRepository::class)
  11.  */
  12. class Contact
  13. {
  14.     public function __toString()
  15.     {
  16.         return "#" $this->id;
  17.     }
  18.     /**
  19.      * @ORM\Column(name="createdAt", type="datetime", nullable=true)
  20.      */
  21.     private $createdAt;
  22.     /**
  23.      * @ORM\Id
  24.      * @ORM\GeneratedValue
  25.      * @ORM\Column(type="integer")
  26.      */
  27.     private $id;
  28.     /**
  29.      * @ORM\Column(type="string", length=255, nullable=true)
  30.      */
  31.     private $firstname;
  32.     /**
  33.      * @ORM\Column(type="string", length=255, nullable=true)
  34.      */
  35.     private $lastname;
  36.     /**
  37.      * @Assert\Email()
  38.      * @ORM\Column(type="string", length=255, nullable=true)
  39.      */
  40.     private $email;
  41.     /**
  42.      * @PhoneNumber()
  43.      * @ORM\Column(type="string", length=255, nullable=true)
  44.      */
  45.     private $phoneNumber;
  46.     /**
  47.      * @ORM\Column(type="string", length=255, nullable=true)
  48.      */
  49.     private $subject;
  50.     /**
  51.      * @ORM\Column(type="text", nullable=true)
  52.      */
  53.     private $message;
  54.     /**
  55.      * @ORM\OneToMany(targetEntity=CustomFile::class, mappedBy="contact", cascade={"persist"})
  56.      */
  57.     private $customFiles;
  58.     /**
  59.      * @ORM\Column(type="string", length=255, nullable=true)
  60.      */
  61.     private $company;
  62.     /**
  63.      * @ORM\Column(type="string", length=255, nullable=true)
  64.      */
  65.     private $address;
  66.     /**
  67.      * @ORM\Column(type="integer", nullable=true)
  68.      */
  69.     private $zipCode;
  70.     /**
  71.      * @ORM\Column(type="string", length=255, nullable=true)
  72.      */
  73.     private $city;
  74.     public function __construct()
  75.     {
  76.         $this->customFiles = new ArrayCollection();
  77.         $this->createdAt = new \DateTime();
  78.     }
  79.     public function getId(): ?int
  80.     {
  81.         return $this->id;
  82.     }
  83.     public function getFirstname(): ?string
  84.     {
  85.         return $this->firstname;
  86.     }
  87.     public function setFirstname(?string $firstname): self
  88.     {
  89.         $this->firstname $firstname;
  90.         return $this;
  91.     }
  92.     public function getLastname(): ?string
  93.     {
  94.         return $this->lastname;
  95.     }
  96.     public function setLastname(?string $lastname): self
  97.     {
  98.         $this->lastname $lastname;
  99.         return $this;
  100.     }
  101.     public function getEmail(): ?string
  102.     {
  103.         return $this->email;
  104.     }
  105.     public function setEmail(?string $email): self
  106.     {
  107.         $this->email $email;
  108.         return $this;
  109.     }
  110.     public function getPhoneNumber(): ?string
  111.     {
  112.         return $this->phoneNumber;
  113.     }
  114.     public function setPhoneNumber(?string $phoneNumber): self
  115.     {
  116.         $this->phoneNumber $phoneNumber;
  117.         return $this;
  118.     }
  119.     public function getSubject(): ?string
  120.     {
  121.         return $this->subject;
  122.     }
  123.     public function setSubject(?string $subject): self
  124.     {
  125.         $this->subject $subject;
  126.         return $this;
  127.     }
  128.     public function getMessage(): ?string
  129.     {
  130.         return $this->message;
  131.     }
  132.     public function setMessage(?string $message): self
  133.     {
  134.         $this->message $message;
  135.         return $this;
  136.     }
  137.     /**
  138.      * @return Collection<int, CustomFile>
  139.      */
  140.     public function getCustomFiles(): Collection
  141.     {
  142.         return $this->customFiles;
  143.     }
  144.     public function addCustomFile(CustomFile $customFile): self
  145.     {
  146.         if (!$this->customFiles->contains($customFile)) {
  147.             $this->customFiles[] = $customFile;
  148.             $customFile->setContact($this);
  149.         }
  150.         return $this;
  151.     }
  152.     public function removeCustomFile(CustomFile $customFile): self
  153.     {
  154.         if ($this->customFiles->removeElement($customFile)) {
  155.             // set the owning side to null (unless already changed)
  156.             if ($customFile->getContact() === $this) {
  157.                 $customFile->setContact(null);
  158.             }
  159.         }
  160.         return $this;
  161.     }
  162.     public function getCreatedAt(): ?\DateTimeInterface
  163.     {
  164.         return $this->createdAt;
  165.     }
  166.     public function setCreatedAt(\DateTimeInterface $createdAt): self
  167.     {
  168.         $this->createdAt $createdAt;
  169.         return $this;
  170.     }
  171.     public function getCompany(): ?string
  172.     {
  173.         return $this->company;
  174.     }
  175.     public function setCompany(?string $company): self
  176.     {
  177.         $this->company $company;
  178.         return $this;
  179.     }
  180.     public function getAddress(): ?string
  181.     {
  182.         return $this->address;
  183.     }
  184.     public function setAddress(?string $address): self
  185.     {
  186.         $this->address $address;
  187.         return $this;
  188.     }
  189.     public function getZipCode(): ?int
  190.     {
  191.         return $this->zipCode;
  192.     }
  193.     public function setZipCode(?int $zipCode): self
  194.     {
  195.         $this->zipCode $zipCode;
  196.         return $this;
  197.     }
  198.     public function getCity(): ?string
  199.     {
  200.         return $this->city;
  201.     }
  202.     public function setCity(?string $city): self
  203.     {
  204.         $this->city $city;
  205.         return $this;
  206.     }
  207. }