<?php
namespace App\Entity;
use App\Repository\OrderAddressRepository;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass=CartAddressRepository::class)
*/
class CartAddress
{
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=100, nullable=true)
*/
protected $firstName;
/**
* @ORM\Column(type="string", length=100, nullable=true)
*/
protected $lastName;
/**
* @ORM\Column(type="string", length=190, nullable=true)
*/
protected $phone;
/**
* @ORM\Column(type="string", length=190, nullable=true)
*/
protected $email;
/**
* @ORM\Column(type="string", length=150, nullable=true)
*/
private $companyName;
/**
* @ORM\Column(type="string", length=10, nullable=true)
*/
private $ico;
/**
* @ORM\Column(type="string", length=12, nullable=true)
*/
private $dic;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $street;
/**
* @ORM\Column(type="string", length=40, nullable=true)
*/
private $streetNumber;
/**
* @ORM\Column(type="string", length=100, nullable=true)
*/
private $city;
/**
* @ORM\Column(type="string", length=40, nullable=true)
*/
private $country;
/**
* @ORM\Column(type="string", length=10, nullable=true)
*/
private $zip;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $note;
/**
* @ORM\Column(type="boolean")
*/
private $isCompany = false;
public function getId(): ?int
{
return $this->id;
}
public function initFromClient(Client $client,$type = 'billing'): self
{
if($type === 'billing'){
$address = $client->getBillingAddress();
$this->setEmail($client->getEmail());
}else{
$address = $client->getDeliveryAddress();
}
if($address instanceof ClientAddress) {
if($type === 'billing'){
$this->setPhone($address->getPhone());
}
$this->setLastName( $address->getLastName() );
$this->setFirstName( $address->getFirstName() );
$this->setCity( $address->getCity() );
$this->setCompanyName( $address->getCompanyName() );
$this->setIsCompany( $address->getisCompany() );
$this->setCountry( $address->getCountry() );
$this->setDic( $address->getDic() );
$this->setIco( $address->getIco() );
$this->setNote( $address->getNote() );
$this->setStreet( $address->getStreet() );
$this->setStreetNumber( $address->getStreetNumber() );
$this->setZip( $address->getZip() );
}
return $this;
}
public function convertToOrder(){
$address = new OrderAddress();
$address->setLastName( $this->getLastName() );
$address->setFirstName( $this->getFirstName() );
$address->setCity( $this->getCity() );
$address->setCompanyName( $this->getCompanyName() );
$address->setIsCompany( $this->getisCompany() );
$address->setCountry( $this->getCountry() );
$address->setDic( $this->getDic() );
$address->setIco( $this->getIco() );
$address->setNote( $this->getNote() );
$address->setStreet( $this->getStreet() );
$address->setStreetNumber( $this->getStreetNumber() );
$address->setZip( $this->getZip() );
$address->setEmail( $this->getEmail() );
$address->setPhone( $this->getPhone() );
return $address;
}
public function getCompanyName(): ?string
{
return $this->companyName;
}
public function setCompanyName(?string $companyName): self
{
$this->companyName = $companyName;
return $this;
}
public function getIco(): ?string
{
return $this->ico;
}
public function setIco(?string $ico): self
{
$this->ico = $ico;
return $this;
}
public function getDic(): ?string
{
return $this->dic;
}
public function setDic(?string $dic): self
{
$this->dic = $dic;
return $this;
}
public function getStreet(): ?string
{
return $this->street;
}
public function setStreet(?string $street): self
{
$this->street = $street;
return $this;
}
public function getStreetNumber(): ?string
{
return $this->streetNumber;
}
public function setStreetNumber(?string $streetNumber): self
{
$this->streetNumber = $streetNumber;
return $this;
}
public function getCity(): ?string
{
return $this->city;
}
public function setCity(?string $city): self
{
$this->city = $city;
return $this;
}
public function getCountry(): ?string
{
return $this->country;
}
public function setCountry(?string $country): self
{
$this->country = $country;
return $this;
}
public function getZip(): ?string
{
return $this->zip;
}
public function setZip(?string $zip): self
{
$this->zip = $zip;
return $this;
}
/**
* Get Email
*
* @return mixed
*/
public function getEmail()
{
return $this->email;
}
/**
* Set Email
*
* @param mixed $email
*/
public function setEmail( $email )
{
$this->email = $email;
}
/**
* Get Note
*
* @return mixed
*/
public function getNote()
{
return $this->note;
}
/**
* Set Note
*
* @param mixed $note
*/
public function setNote( $note )
{
$this->note = $note;
}
public function getFullName( )
{
return sprintf('%s %s',$this->getLastName(),$this->getFirstName());
}
public function getFirstName(): ?string
{
return $this->firstName;
}
public function setFirstName(?string $firstName): self
{
$this->firstName = $firstName;
return $this;
}
public function getLastName(): ?string
{
return $this->lastName;
}
public function setLastName(?string $lastName): self
{
$this->lastName = $lastName;
return $this;
}
/**
* Get Phone
*
* @return mixed
*/
public function getPhone()
{
return $this->phone;
}
/**
* Set Phone
*
* @param mixed $phone
*/
public function setPhone( $phone )
{
$this->phone = $phone;
}
/**
* Get isCompany
*
* @return mixed
*/
public function getisCompany()
{
return $this->isCompany;
}
/**
* Set IsCompany
*
* @param mixed $isCompany
*/
public function setIsCompany( $isCompany )
{
$this->isCompany = $isCompany;
}
}