vendor/crea/tools-bundle/src/Entity/Geographic/City.php line 24

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace Crea\ToolsBundle\Entity\Geographic;
  4. use Crea\ToolsBundle\Repository\Geographic\CityRepository;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. /**
  9. * @ORM\Entity(repositoryClass=CityRepository::class)
  10. *
  11. * @ORM\Table(
  12. * name="geographic_city",
  13. * indexes={
  14. *
  15. * @ORM\Index(name="geographic_city_place", columns={"country_id", "place"}),
  16. * @ORM\Index(name="geographic_city_zipcode", columns={"country_id", "zipcode"})
  17. * }
  18. * )
  19. */
  20. class City implements \Stringable
  21. {
  22. /**
  23. * @ORM\Id
  24. *
  25. * @ORM\GeneratedValue
  26. *
  27. * @ORM\Column(type="integer")
  28. */
  29. private ?int $id;
  30. /**
  31. * @ORM\ManyToOne(targetEntity="Crea\ToolsBundle\Entity\Geographic\Country", inversedBy="cities")
  32. *
  33. * @ORM\JoinColumn(nullable=false)
  34. */
  35. private Country $country;
  36. /**
  37. * @ORM\Column(type="string", nullable=false)
  38. */
  39. private string $zipcode;
  40. /**
  41. * @ORM\Column(type="string", nullable=false)
  42. */
  43. private string $place;
  44. /**
  45. * @ORM\Column(type="string", nullable=true)
  46. */
  47. private ?string $state = null;
  48. /**
  49. * @ORM\Column(type="string", nullable=true)
  50. */
  51. private ?string $stateCode = null;
  52. /**
  53. * @ORM\Column(type="string", nullable=true)
  54. */
  55. private ?string $province = null;
  56. /**
  57. * @ORM\Column(type="string", nullable=true)
  58. */
  59. private ?string $provinceCode = null;
  60. /**
  61. * @ORM\Column(type="string", nullable=true)
  62. */
  63. private ?string $community = null;
  64. /**
  65. * @ORM\Column(type="string", nullable=true)
  66. */
  67. private ?string $communityCode = null;
  68. /**
  69. * @ORM\Column(type="string", nullable=false)
  70. */
  71. private string $latitude;
  72. /**
  73. * @ORM\Column(type="string", nullable=false)
  74. */
  75. private string $longitude;
  76. /**
  77. * @var Collection<int, Address>
  78. *
  79. * @ORM\OneToMany(targetEntity=Address::class, mappedBy="city")
  80. */
  81. private Collection $addresses;
  82. public function __construct()
  83. {
  84. $this->addresses = new ArrayCollection();
  85. }
  86. public function __toString(): string
  87. {
  88. return $this->getZipcode().' '.$this->getPlace().' - '.$this->getCountry();
  89. }
  90. public function getId(): ?int
  91. {
  92. return $this->id;
  93. }
  94. public function setId(?int $id): self
  95. {
  96. $this->id = $id;
  97. return $this;
  98. }
  99. public function getCountry(): Country
  100. {
  101. return $this->country;
  102. }
  103. public function setCountry(Country $country): self
  104. {
  105. $this->country = $country;
  106. return $this;
  107. }
  108. public function getZipcode(): string
  109. {
  110. return $this->zipcode;
  111. }
  112. public function setZipcode(string $zipcode): self
  113. {
  114. $this->zipcode = $zipcode;
  115. return $this;
  116. }
  117. public function getPlace(): string
  118. {
  119. return $this->place;
  120. }
  121. public function setPlace(string $place): self
  122. {
  123. $this->place = $place;
  124. return $this;
  125. }
  126. public function getState(): ?string
  127. {
  128. return $this->state;
  129. }
  130. public function setState(?string $state): self
  131. {
  132. $this->state = $state;
  133. return $this;
  134. }
  135. public function getStateCode(): ?string
  136. {
  137. return $this->stateCode;
  138. }
  139. public function setStateCode(?string $stateCode): self
  140. {
  141. $this->stateCode = $stateCode;
  142. return $this;
  143. }
  144. public function getProvince(): ?string
  145. {
  146. return $this->province;
  147. }
  148. public function setProvince(?string $province): self
  149. {
  150. $this->province = $province;
  151. return $this;
  152. }
  153. public function getProvinceCode(): ?string
  154. {
  155. return $this->provinceCode;
  156. }
  157. public function setProvinceCode(?string $provinceCode): self
  158. {
  159. $this->provinceCode = $provinceCode;
  160. return $this;
  161. }
  162. public function getCommunity(): ?string
  163. {
  164. return $this->community;
  165. }
  166. public function setCommunity(?string $community): self
  167. {
  168. $this->community = $community;
  169. return $this;
  170. }
  171. public function getCommunityCode(): ?string
  172. {
  173. return $this->communityCode;
  174. }
  175. public function setCommunityCode(?string $communityCode): self
  176. {
  177. $this->communityCode = $communityCode;
  178. return $this;
  179. }
  180. public function getLatitude(): string
  181. {
  182. return $this->latitude;
  183. }
  184. public function setLatitude(string $latitude): self
  185. {
  186. $this->latitude = $latitude;
  187. return $this;
  188. }
  189. public function getLongitude(): string
  190. {
  191. return $this->longitude;
  192. }
  193. public function setLongitude(string $longitude): self
  194. {
  195. $this->longitude = $longitude;
  196. return $this;
  197. }
  198. /**
  199. * @return Collection<int, Address>
  200. */
  201. public function getAddresses()
  202. {
  203. return $this->addresses;
  204. }
  205. /**
  206. * @param Collection<int, Address> $addresses
  207. */
  208. public function setAddresses(Collection $addresses): self
  209. {
  210. $this->addresses = $addresses;
  211. return $this;
  212. }
  213. public function addAddress(Address $address): self
  214. {
  215. if (!$this->addresses->contains($address)) {
  216. $this->addresses[] = $address;
  217. $address->setCity($this);
  218. }
  219. return $this;
  220. }
  221. public function removeAddress(Address $address): self
  222. {
  223. if ($this->addresses->removeElement($address)) {
  224. if ($address->getCity() === $this) {
  225. $address->setCity(null);
  226. }
  227. }
  228. return $this;
  229. }
  230. }