<?php
namespace App\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass="App\Repository\CustomerInvoiceAddressRepository")
*/
class CustomerInvoiceAddress
{
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=255, nullable=false)
*/
private $name;
/**
* @ORM\Column(type="bigint")
*/
private $nip;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $zipCode;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $city;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $street;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $propertyNumber;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $apartmentNumber;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Customer", inversedBy="addresses", cascade={"remove","persist"})
* @ORM\JoinColumn(name="customer_id", referencedColumnName="id", nullable=false)
*/
private $customer;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Inquiry", mappedBy="recipient", orphanRemoval=true)
*/
private $inquiries;
public function __construct()
{
$this->inquiries = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getName()
{
return $this->name;
}
public function setName($name): void
{
$this->name = $name;
}
/** @return mixed */
public function getNip()
{
return $this->nip;
}
/** @param mixed $nip */
public function setNip($nip): void
{
$this->nip = $nip;
}
public function getApartmentNumber()
{
return $this->apartmentNumber;
}
public function getCity()
{
return $this->city;
}
public function getPropertyNumber()
{
return $this->propertyNumber;
}
public function getStreet()
{
return $this->street;
}
public function getZipCode()
{
return $this->zipCode;
}
public function setApartmentNumber($apartmentNumber)
{
$this->apartmentNumber = $apartmentNumber;
}
public function setCity($city)
{
$this->city = $city;
}
public function setPropertyNumber($propertyNumber)
{
$this->propertyNumber = $propertyNumber;
}
public function setStreet($street)
{
$this->street = $street;
}
public function setZipCode($zipCode)
{
$this->zipCode = $zipCode;
}
public function getCustomer(): Customer
{
return $this->customer;
}
public function setCustomer(Customer $customer): self
{
$this->customer = $customer;
return $this;
}
/**
* @return Collection|Inquiry[]
*/
public function getInquiries(): Collection
{
return $this->inquiries;
}
public function addInquiry(Inquiry $inquiry): self
{
if (!$this->inquiries->contains($inquiry)) {
$this->inquiries[] = $inquiry;
$inquiry->setInvoiceAddress($this);
}
return $this;
}
public function removeInquiry(Inquiry $inquiry): self
{
if ($this->inquiries->contains($inquiry)) {
$this->inquiries->removeElement($inquiry);
// set the owning side to null (unless already changed)
if ($inquiry->getInvoiceAddress() === $this) {
$inquiry->setInvoiceAddress(null);
}
}
return $this;
}
public function __toString()
{
$address = $this->name . ', NIP:' . $this->nip . ', ' . $this->zipCode . ' ' . $this->city . ', ' . $this->street . ' ' . $this->propertyNumber;
$address .= ($this->apartmentNumber != '') ? '/' . $this->apartmentNumber : '';
return $address;
}
}