src/Entity/Address.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\ORM\Mapping as ORM;
  4. /**
  5. * AddressBook
  6. *
  7. * @ORM\Table(name="address_book", indexes={@ORM\Index(name="idx_address_book_customers_id", columns={"customers_id"})})
  8. * @ORM\Entity(repositoryClass="App\Repository\AddressRepository")
  9. */
  10. class Address
  11. {
  12. /**
  13. * @var int
  14. *
  15. * @ORM\Column(name="address_book_id", type="integer", nullable=false)
  16. * @ORM\Id
  17. * @ORM\GeneratedValue(strategy="IDENTITY")
  18. */
  19. private $id;
  20. /**
  21. * @ORM\ManyToOne(targetEntity="App\Entity\Customer")
  22. * @ORM\JoinColumn(name="customers_id", referencedColumnName="customers_id", onDelete="CASCADE")
  23. */
  24. private $customer;
  25. /**
  26. * @var string
  27. *
  28. * @ORM\Column(name="entry_gender", type="string", length=1, nullable=false, options={"fixed"=true})
  29. */
  30. private $gender = '';
  31. /**
  32. * @var string|null
  33. *
  34. * @ORM\Column(name="entry_company", type="string", length=64, nullable=true)
  35. */
  36. private $company;
  37. /**
  38. * @var string|null
  39. *
  40. * @ORM\Column(name="entry_company_tax_id", type="string", length=32, nullable=true)
  41. */
  42. private $companyTaxId;
  43. /**
  44. * @var string
  45. *
  46. * @ORM\Column(name="entry_firstname", type="string", length=32, nullable=false)
  47. */
  48. private $firstname = '';
  49. /**
  50. * @var string
  51. *
  52. * @ORM\Column(name="entry_lastname", type="string", length=32, nullable=false)
  53. */
  54. private $lastname = '';
  55. /**
  56. * @var string
  57. *
  58. * @ORM\Column(name="entry_street_address", type="string", length=64, nullable=false)
  59. */
  60. private $streetAddress = '';
  61. /**
  62. * @var string|null
  63. *
  64. * @ORM\Column(name="entry_suburb", type="string", length=32, nullable=true)
  65. */
  66. private $suburb;
  67. /**
  68. * @var string
  69. *
  70. * @ORM\Column(name="entry_postcode", type="string", length=10, nullable=false)
  71. */
  72. private $postcode = '';
  73. /**
  74. * @var string
  75. *
  76. * @ORM\Column(name="entry_city", type="string", length=32, nullable=false)
  77. */
  78. private $city = '';
  79. /**
  80. * @var string|null
  81. *
  82. * @ORM\Column(name="entry_state", type="string", length=32, nullable=true)
  83. */
  84. private $state;
  85. /**
  86. * @var string|null
  87. *
  88. * @ORM\Column(name="entry_phone", type="string", length=32, nullable=true)
  89. */
  90. private $phone;
  91. /**
  92. * @ORM\ManyToOne(targetEntity="App\Entity\Country")
  93. * @ORM\JoinColumn(name="entry_country_id", referencedColumnName="countries_id")
  94. */
  95. private $country;
  96. /**
  97. * @var string|null
  98. *
  99. * @ORM\Column(name="entry_email", type="string", length=100, nullable=true)
  100. */
  101. private $email;
  102. /**
  103. * @ORM\Column(name="entry_zone_id", type="integer", nullable=false)
  104. */
  105. private $zoneId = '0';
  106. public function getId() {
  107. return $this->id;
  108. }
  109. public function getCustomer() {
  110. return $this->customer;
  111. }
  112. public function getGender() {
  113. return $this->gender;
  114. }
  115. public function getCompany() {
  116. return $this->company;
  117. }
  118. public function getCompanyTaxId() {
  119. return $this->companyTaxId;
  120. }
  121. public function getFirstname() {
  122. return $this->firstname;
  123. }
  124. public function getLastname() {
  125. return $this->lastname;
  126. }
  127. public function getFullname() {
  128. return $this->getGender().' '.$this->getFirstname().' '.$this->getLastname();
  129. }
  130. public function getAddress1() {
  131. return $this->getStreetAddress();
  132. }
  133. public function getStreetAddress() {
  134. return $this->streetAddress;
  135. }
  136. public function getAddress2() {
  137. return $this->getSuburb();
  138. }
  139. public function getSuburb() {
  140. return $this->suburb;
  141. }
  142. public function getPostcode() {
  143. return $this->postcode;
  144. }
  145. public function getCity() {
  146. return $this->city;
  147. }
  148. public function getState() {
  149. return $this->state;
  150. }
  151. public function getCountry() {
  152. return $this->country;
  153. }
  154. public function getZoneId() {
  155. return $this->zoneId;
  156. }
  157. public function getPhone(): ?string {
  158. return $this->phone;
  159. }
  160. public function getEmail(): ?string {
  161. return $this->email;
  162. }
  163. public function setCustomer($customer) {
  164. $this->customer = $customer;
  165. }
  166. public function setGender($gender) {
  167. $this->gender = $gender;
  168. }
  169. public function setCompany($company) {
  170. $this->company = $company;
  171. }
  172. public function setCompanyTaxId($companyTaxId) {
  173. $this->companyTaxId = $companyTaxId;
  174. }
  175. public function setFirstname($firstname) {
  176. $this->firstname = $firstname;
  177. }
  178. public function setLastname($lastname) {
  179. $this->lastname = $lastname;
  180. }
  181. public function setAddress1($streetAddress) {
  182. $this->setStreetAddress($streetAddress);
  183. }
  184. public function setStreetAddress($streetAddress) {
  185. $this->streetAddress = $streetAddress;
  186. }
  187. public function setAddress2($streetAddress) {
  188. $this->setSuburb($streetAddress);
  189. }
  190. public function setSuburb($suburb) {
  191. $this->suburb = $suburb;
  192. }
  193. public function setPostcode($postcode) {
  194. $this->postcode = $postcode;
  195. }
  196. public function setCity($city) {
  197. $this->city = $city;
  198. }
  199. public function setState($state) {
  200. $this->state = $state;
  201. }
  202. public function setCountry($country) {
  203. $this->country = $country;
  204. }
  205. public function setZoneId($zoneId) {
  206. $this->zoneId = $zoneId;
  207. }
  208. public function setPhone(?string $phone): void {
  209. $this->phone = $phone;
  210. }
  211. public function setEmail(?string $email): void {
  212. $this->email = $email;
  213. }
  214. public function toArray() : array{
  215. $output = [
  216. 'id' => $this->getId(),
  217. 'gender' => $this->getGender(),
  218. 'firstname' => $this->getFirstname(),
  219. 'lastname' => $this->getLastname(),
  220. 'company' => $this->getCompany(),
  221. 'streetAddress' => $this->getStreetAddress(),
  222. 'suburb' => $this->getSuburb(),
  223. 'city' => $this->getCity(),
  224. 'postcode' => $this->getPostcode(),
  225. 'state' => $this->getState(),
  226. 'country' => $this->getCountry()->toArray(),
  227. 'phone' => $this->getPhone(),
  228. 'email' => $this->getEmail(),
  229. // 'customer' => $this->getCustomer()->toArray()
  230. ];
  231. return $output;
  232. }
  233. }