src/Core/Entity/Country.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Core\Entity;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Symfony\Component\Serializer\Annotation\Groups;
  7. /**
  8. * @ORM\Entity(repositoryClass="App\Core\Repository\CountryRepository")
  9. */
  10. class Country
  11. {
  12. /**
  13. * @ORM\Id()
  14. * @ORM\GeneratedValue()
  15. * @ORM\Column(type="integer")
  16. * @Groups("main")
  17. */
  18. private $id;
  19. /**
  20. * @ORM\Column(type="string", length=50)
  21. * @Groups("main")
  22. */
  23. private $nombre;
  24. /**
  25. * @ORM\Column(type="string", length=3)
  26. * @Groups("main")
  27. */
  28. private $sortname;
  29. /**
  30. * @ORM\Column(type="integer")
  31. * @Groups("main")
  32. */
  33. private $codigoTelefonico;
  34. /**
  35. * @ORM\OneToMany(targetEntity="App\Core\Entity\State", mappedBy="country")
  36. */
  37. private $states;
  38. public function __construct()
  39. {
  40. $this->states = new ArrayCollection();
  41. }
  42. public function getId(): ?int
  43. {
  44. return $this->id;
  45. }
  46. public function getNombre(): ?string
  47. {
  48. return $this->nombre;
  49. }
  50. public function setNombre(string $nombre): self
  51. {
  52. $this->nombre = $nombre;
  53. return $this;
  54. }
  55. public function getSortname(): ?string
  56. {
  57. return $this->sortname;
  58. }
  59. public function setSortname(string $sortname): self
  60. {
  61. $this->sortname = $sortname;
  62. return $this;
  63. }
  64. public function getCodigoTelefonico(): ?int
  65. {
  66. return $this->codigoTelefonico;
  67. }
  68. public function setCodigoTelefonico(int $codigoTelefonico): self
  69. {
  70. $this->codigoTelefonico = $codigoTelefonico;
  71. return $this;
  72. }
  73. /**
  74. * @return Collection|State[]
  75. */
  76. public function getStates(): Collection
  77. {
  78. return $this->states;
  79. }
  80. public function addState(State $state): self
  81. {
  82. if (!$this->states->contains($state)) {
  83. $this->states[] = $state;
  84. $state->setCountry($this);
  85. }
  86. return $this;
  87. }
  88. public function removeState(State $state): self
  89. {
  90. if ($this->states->contains($state)) {
  91. $this->states->removeElement($state);
  92. // set the owning side to null (unless already changed)
  93. if ($state->getCountry() === $this) {
  94. $state->setCountry(null);
  95. }
  96. }
  97. return $this;
  98. }
  99. }