src/Entity/City.php line 15
<?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)* @ORM\Table(name="city")* @ORM\HasLifecycleCallbacks()*/class City{/*** @ORM\Id* @ORM\GeneratedValue* @ORM\Column(type="integer")*/private ?int $id = null;/*** @ORM\ManyToOne(targetEntity=Country::class, inversedBy="cities")* @ORM\JoinColumn(nullable=false)*/private Country $country;/*** @ORM\Column(type="string", length=100)*/private string $name;/*** @ORM\Column(type="string", length=120, unique=true)*/private string $slug;/*** @ORM\Column(type="boolean", options={"default": true})*/private bool $isActive = true;/*** @ORM\Column(type="datetime_immutable")*/private \DateTimeImmutable $createdAt;/*** @ORM\OneToMany(targetEntity=Location::class, mappedBy="city", cascade={"persist"}, orphanRemoval=true)*/private Collection $locations;public function __construct(){$this->locations = new ArrayCollection();$this->createdAt = new \DateTimeImmutable();}public function getId(): ?int{return $this->id;}public function getCountry(): Country{return $this->country;}public function setCountry(?Country $country): self{$this->country = $country;return $this;}public function getName(): string{return $this->name;}public function setName(string $name): self{$this->name = $name;return $this;}public function getSlug(): string{return $this->slug;}public function setSlug(string $slug): self{$this->slug = $slug;return $this;}public function isActive(): bool{return $this->isActive;}public function setIsActive(bool $isActive): self{$this->isActive = $isActive;return $this;}public function getCreatedAt(): \DateTimeImmutable{return $this->createdAt;}public function getLocations(): Collection{return $this->locations;}public function addLocation(Location $location): self{if (!$this->locations->contains($location)) {$this->locations->add($location);$location->setCity($this);}return $this;}public function removeLocation(Location $location): self{if ($this->locations->removeElement($location)) {if ($location->getCity() === $this) {$location->setCity(null);}}return $this;}public function __toString(): string{return ($this->title ?? '');}}