src/Entity/CustomerContact.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Entity\Traits\EntityTrait;
  4. use App\Repository\CustomerContactRepository;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. /**
  9.  * @ORM\Entity(repositoryClass=CustomerContactRepository::class)
  10.  */
  11. class CustomerContact
  12. {
  13.     use EntityTrait{
  14.         EntityTrait::__construct as private __entityConstruct;
  15.     }
  16.     /**
  17.      * @ORM\Column(type="string", length=255)
  18.      */
  19.     private $address;
  20.     /**
  21.      * @ORM\Column(type="string", length=255)
  22.      */
  23.     private $postal_code;
  24.     /**
  25.      * @ORM\Column(type="string", length=255)
  26.      */
  27.     private $city;
  28.     /**
  29.      * @ORM\Column(type="string", length=255)
  30.      */
  31.     private $lastname;
  32.     /**
  33.      * @ORM\Column(type="string", length=255)
  34.      */
  35.     private $firstname;
  36.     /**
  37.      * @ORM\Column(type="string", length=255)
  38.      */
  39.     private $position_in_company;
  40.     /**
  41.      * @ORM\Column(type="string", length=255)
  42.      */
  43.     private $phone;
  44.     /**
  45.      * @ORM\Column(type="string", length=255)
  46.      */
  47.     private $email;
  48.     /**
  49.      * @ORM\ManyToOne(targetEntity=Customer::class, inversedBy="customerContacts")
  50.      */
  51.     private $customer;
  52.     /**
  53.      * @ORM\OneToMany(targetEntity=Chantier::class, mappedBy="customer_contact")
  54.      */
  55.     private $chantiers;
  56.     /**
  57.      * @ORM\OneToMany(targetEntity=Event::class, mappedBy="customerContact")
  58.      */
  59.     private $events;
  60.     /**
  61.      * @ORM\Column(type="string", length=255, nullable=true)
  62.      */
  63.     private $additionalPhone;
  64.     public function __construct()
  65.     {
  66.         $this->__entityConstruct();
  67.         $this->chantiers = new ArrayCollection();
  68.         $this->events = new ArrayCollection();
  69.     }
  70.     public function getAddress(): ?string
  71.     {
  72.         return $this->address;
  73.     }
  74.     public function setAddress(string $address): self
  75.     {
  76.         $this->address $address;
  77.         return $this;
  78.     }
  79.     public function getPostalCode(): ?string
  80.     {
  81.         return $this->postal_code;
  82.     }
  83.     public function setPostalCode(string $postal_code): self
  84.     {
  85.         $this->postal_code $postal_code;
  86.         return $this;
  87.     }
  88.     public function getCity(): ?string
  89.     {
  90.         return $this->city;
  91.     }
  92.     public function setCity(string $city): self
  93.     {
  94.         $this->city $city;
  95.         return $this;
  96.     }
  97.     public function getLastname(): ?string
  98.     {
  99.         return $this->lastname;
  100.     }
  101.     public function setLastname(string $lastname): self
  102.     {
  103.         $this->lastname $lastname;
  104.         return $this;
  105.     }
  106.     public function getFirstname(): ?string
  107.     {
  108.         return $this->firstname;
  109.     }
  110.     public function setFirstname(string $firstname): self
  111.     {
  112.         $this->firstname $firstname;
  113.         return $this;
  114.     }
  115.     public function getPositionInCompany(): ?string
  116.     {
  117.         return $this->position_in_company;
  118.     }
  119.     public function setPositionInCompany(string $position_in_company): self
  120.     {
  121.         $this->position_in_company $position_in_company;
  122.         return $this;
  123.     }
  124.     public function getPhone(): ?string
  125.     {
  126.         return $this->phone;
  127.     }
  128.     public function setPhone(string $phone): self
  129.     {
  130.         $this->phone $phone;
  131.         return $this;
  132.     }
  133.     public function getEmail(): ?string
  134.     {
  135.         return $this->email;
  136.     }
  137.     public function setEmail(string $email): self
  138.     {
  139.         $this->email $email;
  140.         return $this;
  141.     }
  142.     public function getCustomer(): ?Customer
  143.     {
  144.         return $this->customer;
  145.     }
  146.     public function setCustomer(?Customer $customer): self
  147.     {
  148.         $this->customer $customer;
  149.         return $this;
  150.     }
  151.     /**
  152.      * @return Collection|Chantier[]
  153.      */
  154.     public function getChantiers(): Collection
  155.     {
  156.         return $this->chantiers;
  157.     }
  158.     public function addChantier(Chantier $chantier): self
  159.     {
  160.         if (!$this->chantiers->contains($chantier)) {
  161.             $this->chantiers[] = $chantier;
  162.             $chantier->setCustomerContact($this);
  163.         }
  164.         return $this;
  165.     }
  166.     public function removeChantier(Chantier $chantier): self
  167.     {
  168.         if ($this->chantiers->removeElement($chantier)) {
  169.             // set the owning side to null (unless already changed)
  170.             if ($chantier->getCustomerContact() === $this) {
  171.                 $chantier->setCustomerContact(null);
  172.             }
  173.         }
  174.         return $this;
  175.     }
  176.     public function __toString(){
  177.         return $this->getCustomer()->getCompany().' - '.$this->getFirstname().' '.$this->getLastname();
  178.     }
  179.     /**
  180.      * @return Collection|Event[]
  181.      */
  182.     public function getEvents(): Collection
  183.     {
  184.         return $this->events;
  185.     }
  186.     public function addEvent(Event $event): self
  187.     {
  188.         if (!$this->events->contains($event)) {
  189.             $this->events[] = $event;
  190.             $event->setCustomerContact($this);
  191.         }
  192.         return $this;
  193.     }
  194.     public function removeEvent(Event $event): self
  195.     {
  196.         if ($this->events->removeElement($event)) {
  197.             // set the owning side to null (unless already changed)
  198.             if ($event->getCustomerContact() === $this) {
  199.                 $event->setCustomerContact(null);
  200.             }
  201.         }
  202.         return $this;
  203.     }
  204.     public function getAdditionalPhone()
  205.     {
  206.         return $this->additionalPhone;
  207.     }
  208.     public function setAdditionalPhone($additionalPhone): self
  209.     {
  210.         $this->additionalPhone $additionalPhone;
  211.         return $this;
  212.     }
  213. }