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 $address;
  62.     /**
  63.      * @ORM\Column(type="string", length=255, nullable=true)
  64.      */
  65.     private $city;
  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 $country;
  74.     /**
  75.      * @ORM\Column(type="string", length=255, nullable=true)
  76.      */
  77.     private $company;
  78.     public function __construct()
  79.     {
  80.         $this->customFiles = new ArrayCollection();
  81.         $this->createdAt = new \DateTime();
  82.     }
  83.     public function getId(): ?int
  84.     {
  85.         return $this->id;
  86.     }
  87.     public function getFirstname(): ?string
  88.     {
  89.         return $this->firstname;
  90.     }
  91.     public function setFirstname(?string $firstname): self
  92.     {
  93.         $this->firstname $firstname;
  94.         return $this;
  95.     }
  96.     public function getLastname(): ?string
  97.     {
  98.         return $this->lastname;
  99.     }
  100.     public function setLastname(?string $lastname): self
  101.     {
  102.         $this->lastname $lastname;
  103.         return $this;
  104.     }
  105.     public function getEmail(): ?string
  106.     {
  107.         return $this->email;
  108.     }
  109.     public function setEmail(?string $email): self
  110.     {
  111.         $this->email $email;
  112.         return $this;
  113.     }
  114.     public function getPhoneNumber(): ?string
  115.     {
  116.         return $this->phoneNumber;
  117.     }
  118.     public function setPhoneNumber(?string $phoneNumber): self
  119.     {
  120.         $this->phoneNumber $phoneNumber;
  121.         return $this;
  122.     }
  123.     public function getSubject(): ?string
  124.     {
  125.         return $this->subject;
  126.     }
  127.     public function setSubject(?string $subject): self
  128.     {
  129.         $this->subject $subject;
  130.         return $this;
  131.     }
  132.     public function getMessage(): ?string
  133.     {
  134.         return $this->message;
  135.     }
  136.     public function setMessage(?string $message): self
  137.     {
  138.         $this->message $message;
  139.         return $this;
  140.     }
  141.     /**
  142.      * @return Collection<int, CustomFile>
  143.      */
  144.     public function getCustomFiles(): Collection
  145.     {
  146.         return $this->customFiles;
  147.     }
  148.     public function addCustomFile(CustomFile $customFile): self
  149.     {
  150.         if (!$this->customFiles->contains($customFile)) {
  151.             $this->customFiles[] = $customFile;
  152.             $customFile->setContact($this);
  153.         }
  154.         return $this;
  155.     }
  156.     public function removeCustomFile(CustomFile $customFile): self
  157.     {
  158.         if ($this->customFiles->removeElement($customFile)) {
  159.             // set the owning side to null (unless already changed)
  160.             if ($customFile->getContact() === $this) {
  161.                 $customFile->setContact(null);
  162.             }
  163.         }
  164.         return $this;
  165.     }
  166.     public function getCreatedAt(): ?\DateTimeInterface
  167.     {
  168.         return $this->createdAt;
  169.     }
  170.     public function setCreatedAt(\DateTimeInterface $createdAt): self
  171.     {
  172.         $this->createdAt $createdAt;
  173.         return $this;
  174.     }
  175.     public function getAddress(): ?string
  176.     {
  177.         return $this->address;
  178.     }
  179.     public function setAddress(?string $address): self
  180.     {
  181.         $this->address $address;
  182.         return $this;
  183.     }
  184.     public function getCity(): ?string
  185.     {
  186.         return $this->city;
  187.     }
  188.     public function setCity(?string $city): self
  189.     {
  190.         $this->city $city;
  191.         return $this;
  192.     }
  193.     public function getZipCode(): ?int
  194.     {
  195.         return $this->zipCode;
  196.     }
  197.     public function setZipCode(?int $zipCode): self
  198.     {
  199.         $this->zipCode $zipCode;
  200.         return $this;
  201.     }
  202.     public function getCountry(): ?string
  203.     {
  204.         return $this->country;
  205.     }
  206.     public function setCountry(?string $country): self
  207.     {
  208.         $this->country $country;
  209.         return $this;
  210.     }
  211.     public function getCompany(): ?string
  212.     {
  213.         return $this->company;
  214.     }
  215.     public function setCompany(?string $company): self
  216.     {
  217.         $this->company $company;
  218.         return $this;
  219.     }
  220. }