src/Flexy/ShopBundle/Entity/Shipping/City.php line 15

  1. <?php
  2. namespace App\Flexy\ShopBundle\Entity\Shipping;
  3. use ApiPlatform\Core\Annotation\ApiResource;
  4. use App\Flexy\ShopBundle\Entity\Customer\CustomerAddress;
  5. use App\Flexy\ShopBundle\Entity\Store\Store;
  6. use App\Flexy\ShopBundle\Repository\Shipping\CityRepository;
  7. use Doctrine\Common\Collections\ArrayCollection;
  8. use Doctrine\Common\Collections\Collection;
  9. use Doctrine\ORM\Mapping as ORM;
  10. #[ApiResource]
  11. #[ORM\Entity(repositoryClassCityRepository::class)]
  12. class City implements \Stringable
  13. {
  14.     #[ORM\Id]
  15.     #[ORM\GeneratedValue]
  16.     #[ORM\Column(type'integer')]
  17.     private $id;
  18.     #[ORM\Column(type'string'length255)]
  19.     private ?string $name null;
  20.     #[ORM\Column(type'text'nullabletrue)]
  21.     private ?string $description null;
  22.     #[ORM\OneToMany(targetEntityCityRegion::class, mappedBy'city')]
  23.     private \Doctrine\Common\Collections\Collection|array $regions;
  24.     #[ORM\OneToMany(targetEntityDepartement::class, mappedBy'city')]
  25.     private \Doctrine\Common\Collections\Collection|array $departements;
  26.     #[ORM\OneToMany(targetEntityCustomerAddress::class, mappedBy'city')]
  27.     private \Doctrine\Common\Collections\Collection|array $customerAddresses;
  28.     #[ORM\ManyToMany(targetEntityStepType::class, mappedBy'excludeCities')]
  29.     private Collection $stepTypes;
  30.     #[ORM\OneToMany(mappedBy'city'targetEntityStore::class, orphanRemovaltrue)]
  31.     private Collection $stores;
  32.     public function __toString(): string
  33.     {
  34.         return (string) $this->name;
  35.     }
  36.     public function __construct()
  37.     {
  38.         $this->regions = new ArrayCollection();
  39.         $this->departements = new ArrayCollection();
  40.         $this->customerAddresses = new ArrayCollection();
  41.         $this->stepTypes = new ArrayCollection();
  42.         $this->stores = new ArrayCollection();
  43.     }
  44.     public function getId(): ?int
  45.     {
  46.         return $this->id;
  47.     }
  48.     public function getName(): ?string
  49.     {
  50.         return $this->name;
  51.     }
  52.     public function setName(string $name): self
  53.     {
  54.         $this->name $name;
  55.         return $this;
  56.     }
  57.     public function getDescription(): ?string
  58.     {
  59.         return $this->description;
  60.     }
  61.     public function setDescription(?string $description): self
  62.     {
  63.         $this->description $description;
  64.         return $this;
  65.     }
  66.     /**
  67.      * @return Collection|CityRegion[]
  68.      */
  69.     public function getRegions(): Collection
  70.     {
  71.         return $this->regions;
  72.     }
  73.     public function addRegion(CityRegion $region): self
  74.     {
  75.         if (!$this->regions->contains($region)) {
  76.             $this->regions[] = $region;
  77.             $region->setCity($this);
  78.         }
  79.         return $this;
  80.     }
  81.     public function removeRegion(CityRegion $region): self
  82.     {
  83.         if ($this->regions->removeElement($region)) {
  84.             // set the owning side to null (unless already changed)
  85.             if ($region->getCity() === $this) {
  86.                 $region->setCity(null);
  87.             }
  88.         }
  89.         return $this;
  90.     }
  91.     /**
  92.      * @return Collection|Departement[]
  93.      */
  94.     public function getDepartements(): Collection
  95.     {
  96.         return $this->departements;
  97.     }
  98.     public function addDepartement(Departement $departement): self
  99.     {
  100.         if (!$this->departements->contains($departement)) {
  101.             $this->departements[] = $departement;
  102.             $departement->setCity($this);
  103.         }
  104.         return $this;
  105.     }
  106.     public function removeDepartement(Departement $departement): self
  107.     {
  108.         if ($this->departements->removeElement($departement)) {
  109.             // set the owning side to null (unless already changed)
  110.             if ($departement->getCity() === $this) {
  111.                 $departement->setCity(null);
  112.             }
  113.         }
  114.         return $this;
  115.     }
  116.     /**
  117.      * @return Collection<int, CustomerAddress>
  118.      */
  119.     public function getCustomerAddresses(): Collection
  120.     {
  121.         return $this->customerAddresses;
  122.     }
  123.     public function addCustomerAddress(CustomerAddress $customerAddress): self
  124.     {
  125.         if (!$this->customerAddresses->contains($customerAddress)) {
  126.             $this->customerAddresses[] = $customerAddress;
  127.             $customerAddress->setCity($this);
  128.         }
  129.         return $this;
  130.     }
  131.     public function removeCustomerAddress(CustomerAddress $customerAddress): self
  132.     {
  133.         if ($this->customerAddresses->removeElement($customerAddress)) {
  134.             // set the owning side to null (unless already changed)
  135.             if ($customerAddress->getCity() === $this) {
  136.                 $customerAddress->setCity(null);
  137.             }
  138.         }
  139.         return $this;
  140.     }
  141.     /**
  142.      * @return Collection<int, StepType>
  143.      */
  144.     public function getStepTypes(): Collection
  145.     {
  146.         return $this->stepTypes;
  147.     }
  148.     public function addStepType(StepType $stepType): self
  149.     {
  150.         if (!$this->stepTypes->contains($stepType)) {
  151.             $this->stepTypes->add($stepType);
  152.             $stepType->addExcludeCity($this);
  153.         }
  154.         return $this;
  155.     }
  156.     public function removeStepType(StepType $stepType): self
  157.     {
  158.         if ($this->stepTypes->removeElement($stepType)) {
  159.             $stepType->removeExcludeCity($this);
  160.         }
  161.         return $this;
  162.     }
  163.     /**
  164.      * @return Collection<int, Store>
  165.      */
  166.     public function getStores(): Collection
  167.     {
  168.         return $this->stores;
  169.     }
  170.     public function addStore(Store $store): self
  171.     {
  172.         if (!$this->stores->contains($store)) {
  173.             $this->stores->add($store);
  174.             $store->setCity($this);
  175.         }
  176.         return $this;
  177.     }
  178.     public function removeStore(Store $store): self
  179.     {
  180.         if ($this->stores->removeElement($store)) {
  181.             // set the owning side to null (unless already changed)
  182.             if ($store->getCity() === $this) {
  183.                 $store->setCity(null);
  184.             }
  185.         }
  186.         return $this;
  187.     }
  188. }