<?php
namespace App\Entity;
use App\Repository\ZoneRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: ZoneRepository::class)]
class Zone
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
private $id;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private ?string $name = null;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private ?string $slug = null;
#[ORM\OneToMany(targetEntity: Country::class, mappedBy: 'zone')]
private Collection $countries;
public function __construct()
{
$this->countries = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
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;
}
/**
* @return Collection<int, Country>
*/
public function getCountries(): Collection
{
return $this->countries;
}
public function addCountry(Country $country): self
{
if (!$this->countries->contains($country)) {
$this->countries[] = $country;
$country->setZone($this);
}
return $this;
}
public function removeCountry(Country $country): self
{
if ($this->countries->removeElement($country)) {
// set the owning side to null (unless already changed)
if ($country->getZone() === $this) {
$country->setZone(null);
}
}
return $this;
}
}