<?phpnamespace App\Core\Entity;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use Doctrine\ORM\Mapping as ORM;use Symfony\Component\Serializer\Annotation\Groups;/** * @ORM\Entity(repositoryClass="App\Core\Repository\StateRepository") */class State{ /** * @ORM\Id() * @ORM\GeneratedValue() * @ORM\Column(type="integer") * @Groups("main") */ private $id; /** * @ORM\Column(type="string", length=50) * @Groups("main") */ private $nombre; /** * @ORM\OneToMany(targetEntity="App\Core\Entity\City", mappedBy="state") */ private $cities; /** * @ORM\ManyToOne(targetEntity="App\Core\Entity\Country", inversedBy="states") */ private $country; public function __construct() { $this->cities = new ArrayCollection(); } public function getId(): ?int { return $this->id; } public function getNombre(): ?string { return $this->nombre; } public function setNombre(string $nombre): self { $this->nombre = $nombre; return $this; } /** * @return Collection|City[] */ public function getCities(): Collection { return $this->cities; } public function addCity(City $city): self { if (!$this->cities->contains($city)) { $this->cities[] = $city; $city->setState($this); } return $this; } public function removeCity(City $city): self { if ($this->cities->contains($city)) { $this->cities->removeElement($city); // set the owning side to null (unless already changed) if ($city->getState() === $this) { $city->setState(null); } } return $this; } public function getCountry(): ?Country { return $this->country; } public function setCountry(?Country $country): self { $this->country = $country; return $this; }}