<?php
namespace App\Entity;
use App\Entity\Traits\EntityTrait;
use App\Repository\CustomerContactRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass=CustomerContactRepository::class)
*/
class CustomerContact
{
use EntityTrait{
EntityTrait::__construct as private __entityConstruct;
}
/**
* @ORM\Column(type="string", length=255)
*/
private $address;
/**
* @ORM\Column(type="string", length=255)
*/
private $postal_code;
/**
* @ORM\Column(type="string", length=255)
*/
private $city;
/**
* @ORM\Column(type="string", length=255)
*/
private $lastname;
/**
* @ORM\Column(type="string", length=255)
*/
private $firstname;
/**
* @ORM\Column(type="string", length=255)
*/
private $position_in_company;
/**
* @ORM\Column(type="string", length=255)
*/
private $phone;
/**
* @ORM\Column(type="string", length=255)
*/
private $email;
/**
* @ORM\ManyToOne(targetEntity=Customer::class, inversedBy="customerContacts")
*/
private $customer;
/**
* @ORM\OneToMany(targetEntity=Chantier::class, mappedBy="customer_contact")
*/
private $chantiers;
/**
* @ORM\OneToMany(targetEntity=Event::class, mappedBy="customerContact")
*/
private $events;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $additionalPhone;
public function __construct()
{
$this->__entityConstruct();
$this->chantiers = new ArrayCollection();
$this->events = new ArrayCollection();
}
public function getAddress(): ?string
{
return $this->address;
}
public function setAddress(string $address): self
{
$this->address = $address;
return $this;
}
public function getPostalCode(): ?string
{
return $this->postal_code;
}
public function setPostalCode(string $postal_code): self
{
$this->postal_code = $postal_code;
return $this;
}
public function getCity(): ?string
{
return $this->city;
}
public function setCity(string $city): self
{
$this->city = $city;
return $this;
}
public function getLastname(): ?string
{
return $this->lastname;
}
public function setLastname(string $lastname): self
{
$this->lastname = $lastname;
return $this;
}
public function getFirstname(): ?string
{
return $this->firstname;
}
public function setFirstname(string $firstname): self
{
$this->firstname = $firstname;
return $this;
}
public function getPositionInCompany(): ?string
{
return $this->position_in_company;
}
public function setPositionInCompany(string $position_in_company): self
{
$this->position_in_company = $position_in_company;
return $this;
}
public function getPhone(): ?string
{
return $this->phone;
}
public function setPhone(string $phone): self
{
$this->phone = $phone;
return $this;
}
public function getEmail(): ?string
{
return $this->email;
}
public function setEmail(string $email): self
{
$this->email = $email;
return $this;
}
public function getCustomer(): ?Customer
{
return $this->customer;
}
public function setCustomer(?Customer $customer): self
{
$this->customer = $customer;
return $this;
}
/**
* @return Collection|Chantier[]
*/
public function getChantiers(): Collection
{
return $this->chantiers;
}
public function addChantier(Chantier $chantier): self
{
if (!$this->chantiers->contains($chantier)) {
$this->chantiers[] = $chantier;
$chantier->setCustomerContact($this);
}
return $this;
}
public function removeChantier(Chantier $chantier): self
{
if ($this->chantiers->removeElement($chantier)) {
// set the owning side to null (unless already changed)
if ($chantier->getCustomerContact() === $this) {
$chantier->setCustomerContact(null);
}
}
return $this;
}
public function __toString(){
return $this->getCustomer()->getCompany().' - '.$this->getFirstname().' '.$this->getLastname();
}
/**
* @return Collection|Event[]
*/
public function getEvents(): Collection
{
return $this->events;
}
public function addEvent(Event $event): self
{
if (!$this->events->contains($event)) {
$this->events[] = $event;
$event->setCustomerContact($this);
}
return $this;
}
public function removeEvent(Event $event): self
{
if ($this->events->removeElement($event)) {
// set the owning side to null (unless already changed)
if ($event->getCustomerContact() === $this) {
$event->setCustomerContact(null);
}
}
return $this;
}
public function getAdditionalPhone()
{
return $this->additionalPhone;
}
public function setAdditionalPhone($additionalPhone): self
{
$this->additionalPhone = $additionalPhone;
return $this;
}
}