<?phpnamespace App\Entity;use App\Repository\CityRepository;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use Doctrine\ORM\Mapping as ORM;/** * @ORM\Entity(repositoryClass=CityRepository::class) */class City{ /** * @ORM\Id * @ORM\GeneratedValue * @ORM\Column(type="integer") */ private $id; /** * @ORM\Column(type="string", length=100) */ private $label; /** * @ORM\Column(type="integer", length=2) */ private $code; /** * @ORM\OneToMany(targetEntity=User::class, mappedBy="city") */ private $users; public function __construct() { $this->users = new ArrayCollection(); } public function getId(): ?int { return $this->id; } public function getLabel(): ?string { return $this->label; } public function setLabel(string $label): self { $this->label = $label; return $this; } /** * @return Collection<int, User> */ public function getUsers(): Collection { return $this->users; } public function addUsers(User $user): self { if (!$this->users->contains($user)) { $this->users[] = $user; $user->setCity($this); } return $this; } public function removeUser(User $user): self { if ($this->users->removeElement($user)) { // set the owning side to null (unless already changed) if ($user->getCity() === $this) { $user->setCity(null); } } return $this; } /** * @return mixed */ public function getCode() { return $this->code; } /** * @param mixed $code */ public function setCode($code): void { $this->code = $code; }}