src/Entity/CartAddress.php line 12

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\OrderAddressRepository;
  4. use Doctrine\ORM\Mapping as ORM;
  5. /**
  6. * @ORM\Entity(repositoryClass=CartAddressRepository::class)
  7. */
  8. class CartAddress
  9. {
  10. /**
  11. * @ORM\Id()
  12. * @ORM\GeneratedValue()
  13. * @ORM\Column(type="integer")
  14. */
  15. private $id;
  16. /**
  17. * @ORM\Column(type="string", length=100, nullable=true)
  18. */
  19. protected $firstName;
  20. /**
  21. * @ORM\Column(type="string", length=100, nullable=true)
  22. */
  23. protected $lastName;
  24. /**
  25. * @ORM\Column(type="string", length=190, nullable=true)
  26. */
  27. protected $phone;
  28. /**
  29. * @ORM\Column(type="string", length=190, nullable=true)
  30. */
  31. protected $email;
  32. /**
  33. * @ORM\Column(type="string", length=150, nullable=true)
  34. */
  35. private $companyName;
  36. /**
  37. * @ORM\Column(type="string", length=10, nullable=true)
  38. */
  39. private $ico;
  40. /**
  41. * @ORM\Column(type="string", length=12, nullable=true)
  42. */
  43. private $dic;
  44. /**
  45. * @ORM\Column(type="string", length=255, nullable=true)
  46. */
  47. private $street;
  48. /**
  49. * @ORM\Column(type="string", length=40, nullable=true)
  50. */
  51. private $streetNumber;
  52. /**
  53. * @ORM\Column(type="string", length=100, nullable=true)
  54. */
  55. private $city;
  56. /**
  57. * @ORM\Column(type="string", length=40, nullable=true)
  58. */
  59. private $country;
  60. /**
  61. * @ORM\Column(type="string", length=10, nullable=true)
  62. */
  63. private $zip;
  64. /**
  65. * @ORM\Column(type="string", length=255, nullable=true)
  66. */
  67. private $note;
  68. /**
  69. * @ORM\Column(type="boolean")
  70. */
  71. private $isCompany = false;
  72. public function getId(): ?int
  73. {
  74. return $this->id;
  75. }
  76. public function initFromClient(Client $client,$type = 'billing'): self
  77. {
  78. if($type === 'billing'){
  79. $address = $client->getBillingAddress();
  80. $this->setEmail($client->getEmail());
  81. }else{
  82. $address = $client->getDeliveryAddress();
  83. }
  84. if($address instanceof ClientAddress) {
  85. if($type === 'billing'){
  86. $this->setPhone($address->getPhone());
  87. }
  88. $this->setLastName( $address->getLastName() );
  89. $this->setFirstName( $address->getFirstName() );
  90. $this->setCity( $address->getCity() );
  91. $this->setCompanyName( $address->getCompanyName() );
  92. $this->setIsCompany( $address->getisCompany() );
  93. $this->setCountry( $address->getCountry() );
  94. $this->setDic( $address->getDic() );
  95. $this->setIco( $address->getIco() );
  96. $this->setNote( $address->getNote() );
  97. $this->setStreet( $address->getStreet() );
  98. $this->setStreetNumber( $address->getStreetNumber() );
  99. $this->setZip( $address->getZip() );
  100. }
  101. return $this;
  102. }
  103. public function convertToOrder(){
  104. $address = new OrderAddress();
  105. $address->setLastName( $this->getLastName() );
  106. $address->setFirstName( $this->getFirstName() );
  107. $address->setCity( $this->getCity() );
  108. $address->setCompanyName( $this->getCompanyName() );
  109. $address->setIsCompany( $this->getisCompany() );
  110. $address->setCountry( $this->getCountry() );
  111. $address->setDic( $this->getDic() );
  112. $address->setIco( $this->getIco() );
  113. $address->setNote( $this->getNote() );
  114. $address->setStreet( $this->getStreet() );
  115. $address->setStreetNumber( $this->getStreetNumber() );
  116. $address->setZip( $this->getZip() );
  117. $address->setEmail( $this->getEmail() );
  118. $address->setPhone( $this->getPhone() );
  119. return $address;
  120. }
  121. public function getCompanyName(): ?string
  122. {
  123. return $this->companyName;
  124. }
  125. public function setCompanyName(?string $companyName): self
  126. {
  127. $this->companyName = $companyName;
  128. return $this;
  129. }
  130. public function getIco(): ?string
  131. {
  132. return $this->ico;
  133. }
  134. public function setIco(?string $ico): self
  135. {
  136. $this->ico = $ico;
  137. return $this;
  138. }
  139. public function getDic(): ?string
  140. {
  141. return $this->dic;
  142. }
  143. public function setDic(?string $dic): self
  144. {
  145. $this->dic = $dic;
  146. return $this;
  147. }
  148. public function getStreet(): ?string
  149. {
  150. return $this->street;
  151. }
  152. public function setStreet(?string $street): self
  153. {
  154. $this->street = $street;
  155. return $this;
  156. }
  157. public function getStreetNumber(): ?string
  158. {
  159. return $this->streetNumber;
  160. }
  161. public function setStreetNumber(?string $streetNumber): self
  162. {
  163. $this->streetNumber = $streetNumber;
  164. return $this;
  165. }
  166. public function getCity(): ?string
  167. {
  168. return $this->city;
  169. }
  170. public function setCity(?string $city): self
  171. {
  172. $this->city = $city;
  173. return $this;
  174. }
  175. public function getCountry(): ?string
  176. {
  177. return $this->country;
  178. }
  179. public function setCountry(?string $country): self
  180. {
  181. $this->country = $country;
  182. return $this;
  183. }
  184. public function getZip(): ?string
  185. {
  186. return $this->zip;
  187. }
  188. public function setZip(?string $zip): self
  189. {
  190. $this->zip = $zip;
  191. return $this;
  192. }
  193. /**
  194. * Get Email
  195. *
  196. * @return mixed
  197. */
  198. public function getEmail()
  199. {
  200. return $this->email;
  201. }
  202. /**
  203. * Set Email
  204. *
  205. * @param mixed $email
  206. */
  207. public function setEmail( $email )
  208. {
  209. $this->email = $email;
  210. }
  211. /**
  212. * Get Note
  213. *
  214. * @return mixed
  215. */
  216. public function getNote()
  217. {
  218. return $this->note;
  219. }
  220. /**
  221. * Set Note
  222. *
  223. * @param mixed $note
  224. */
  225. public function setNote( $note )
  226. {
  227. $this->note = $note;
  228. }
  229. public function getFullName( )
  230. {
  231. return sprintf('%s %s',$this->getLastName(),$this->getFirstName());
  232. }
  233. public function getFirstName(): ?string
  234. {
  235. return $this->firstName;
  236. }
  237. public function setFirstName(?string $firstName): self
  238. {
  239. $this->firstName = $firstName;
  240. return $this;
  241. }
  242. public function getLastName(): ?string
  243. {
  244. return $this->lastName;
  245. }
  246. public function setLastName(?string $lastName): self
  247. {
  248. $this->lastName = $lastName;
  249. return $this;
  250. }
  251. /**
  252. * Get Phone
  253. *
  254. * @return mixed
  255. */
  256. public function getPhone()
  257. {
  258. return $this->phone;
  259. }
  260. /**
  261. * Set Phone
  262. *
  263. * @param mixed $phone
  264. */
  265. public function setPhone( $phone )
  266. {
  267. $this->phone = $phone;
  268. }
  269. /**
  270. * Get isCompany
  271. *
  272. * @return mixed
  273. */
  274. public function getisCompany()
  275. {
  276. return $this->isCompany;
  277. }
  278. /**
  279. * Set IsCompany
  280. *
  281. * @param mixed $isCompany
  282. */
  283. public function setIsCompany( $isCompany )
  284. {
  285. $this->isCompany = $isCompany;
  286. }
  287. }