src/Entity/City.php line 11

  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\CityRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. #[ORM\Entity(repositoryClassCityRepository::class)]
  8. class City
  9. {
  10.     #[ORM\Id]
  11.     #[ORM\GeneratedValue]
  12.     #[ORM\Column]
  13.     private ?int $id null;
  14.     #[ORM\Column(length100)]
  15.     private ?string $name null;
  16.     #[ORM\Column(length100)]
  17.     private ?string $slug null;
  18.     #[ORM\Column(length5nullabletrue)]
  19.     private ?string $zipcode null;
  20.     #[ORM\OneToMany(mappedBy'city'targetEntityEmplacement::class)]
  21.     private Collection $emplacements;
  22.     #[ORM\OneToMany(mappedBy'city'targetEntityCustomer::class)]
  23.     private Collection $customers;
  24.     public function __construct()
  25.     {
  26.         $this->emplacements = new ArrayCollection();
  27.         $this->customers = new ArrayCollection();
  28.     }
  29.     public function __toString(): string
  30.     {
  31.         return $this->getName();
  32.     }
  33.     public function getId(): ?int
  34.     {
  35.         return $this->id;
  36.     }
  37.     public function getName(): ?string
  38.     {
  39.         return $this->name;
  40.     }
  41.     public function setName(string $name): self
  42.     {
  43.         $this->name $name;
  44.         return $this;
  45.     }
  46.     public function getSlug(): ?string
  47.     {
  48.         return $this->slug;
  49.     }
  50.     public function setSlug(string $slug): self
  51.     {
  52.         $this->slug $slug;
  53.         return $this;
  54.     }
  55.     public function getZipcode(): ?string
  56.     {
  57.         return $this->zipcode;
  58.     }
  59.     public function setZipcode(?string $zipcode): self
  60.     {
  61.         $this->zipcode $zipcode;
  62.         return $this;
  63.     }
  64.     /**
  65.      * @return Collection<int, Emplacement>
  66.      */
  67.     public function getEmplacements(): Collection
  68.     {
  69.         return $this->emplacements;
  70.     }
  71.     public function addEmplacement(Emplacement $emplacement): self
  72.     {
  73.         if (!$this->emplacements->contains($emplacement)) {
  74.             $this->emplacements->add($emplacement);
  75.             $emplacement->setCity($this);
  76.         }
  77.         return $this;
  78.     }
  79.     public function removeEmplacement(Emplacement $emplacement): self
  80.     {
  81.         if ($this->emplacements->removeElement($emplacement)) {
  82.             // set the owning side to null (unless already changed)
  83.             if ($emplacement->getCity() === $this) {
  84.                 $emplacement->setCity(null);
  85.             }
  86.         }
  87.         return $this;
  88.     }
  89.     /**
  90.      * @return Collection<int, Customer>
  91.      */
  92.     public function getCustomers(): Collection
  93.     {
  94.         return $this->customers;
  95.     }
  96.     public function addCustomer(Customer $customer): self
  97.     {
  98.         if (!$this->customers->contains($customer)) {
  99.             $this->customers->add($customer);
  100.             $customer->setCity($this);
  101.         }
  102.         return $this;
  103.     }
  104.     public function removeCustomer(Customer $customer): self
  105.     {
  106.         if ($this->customers->removeElement($customer)) {
  107.             // set the owning side to null (unless already changed)
  108.             if ($customer->getCity() === $this) {
  109.                 $customer->setCity(null);
  110.             }
  111.         }
  112.         return $this;
  113.     }
  114. }