<?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\CityRepository") */class City{ /** * @ORM\Id() * @ORM\GeneratedValue() * @ORM\Column(type="integer") * @Groups("city") */ private $id; /** * @ORM\Column(type="string", length=50) * @Groups("city") */ private $nombre; /** * @ORM\OneToMany(targetEntity="App\Core\Entity\Direccion", mappedBy="city") */ private $direcciones; /** * @ORM\ManyToOne(targetEntity="App\Core\Entity\State", inversedBy="cities") */ private $state; public function __construct() { $this->direcciones = 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|Direccion[] */ public function getDirecciones(): Collection { return $this->direcciones; } public function addDireccion(Direccion $direccion): self { if (!$this->direcciones->contains($direccion)) { $this->direcciones[] = $direccion; $direccion->setCity($this); } return $this; } public function removeDireccion(Direccion $direccion): self { if ($this->direcciones->contains($direccion)) { $this->direcciones->removeElement($direccion); // set the owning side to null (unless already changed) if ($direccion->getCity() === $this) { $direccion->setCity(null); } } return $this; } public function getState(): ?State { return $this->state; } public function setState(?State $state): self { $this->state = $state; return $this; }}