src/Entity/City.php line 11
<?php
namespace 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]
private ?int $id = null;
#[ORM\Column(length: 100)]
private ?string $name = null;
#[ORM\Column(length: 100)]
private ?string $slug = null;
#[ORM\Column(length: 5, nullable: true)]
private ?string $zipcode = null;
#[ORM\OneToMany(mappedBy: 'city', targetEntity: Emplacement::class)]
private Collection $emplacements;
#[ORM\OneToMany(mappedBy: 'city', targetEntity: Customer::class)]
private Collection $customers;
public function __construct()
{
$this->emplacements = new ArrayCollection();
$this->customers = new ArrayCollection();
}
public function __toString(): string
{
return $this->getName();
}
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;
}
public function getZipcode(): ?string
{
return $this->zipcode;
}
public function setZipcode(?string $zipcode): self
{
$this->zipcode = $zipcode;
return $this;
}
/**
* @return Collection<int, Emplacement>
*/
public function getEmplacements(): Collection
{
return $this->emplacements;
}
public function addEmplacement(Emplacement $emplacement): self
{
if (!$this->emplacements->contains($emplacement)) {
$this->emplacements->add($emplacement);
$emplacement->setCity($this);
}
return $this;
}
public function removeEmplacement(Emplacement $emplacement): self
{
if ($this->emplacements->removeElement($emplacement)) {
// set the owning side to null (unless already changed)
if ($emplacement->getCity() === $this) {
$emplacement->setCity(null);
}
}
return $this;
}
/**
* @return Collection<int, Customer>
*/
public function getCustomers(): Collection
{
return $this->customers;
}
public function addCustomer(Customer $customer): self
{
if (!$this->customers->contains($customer)) {
$this->customers->add($customer);
$customer->setCity($this);
}
return $this;
}
public function removeCustomer(Customer $customer): self
{
if ($this->customers->removeElement($customer)) {
// set the owning side to null (unless already changed)
if ($customer->getCity() === $this) {
$customer->setCity(null);
}
}
return $this;
}
}