src/Flexy/ShopBundle/Entity/Shipping/City.php line 15
<?php
namespace App\Flexy\ShopBundle\Entity\Shipping;
use ApiPlatform\Core\Annotation\ApiResource;
use App\Flexy\ShopBundle\Entity\Customer\CustomerAddress;
use App\Flexy\ShopBundle\Entity\Store\Store;
use App\Flexy\ShopBundle\Repository\Shipping\CityRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
#[ApiResource]
#[ORM\Entity(repositoryClass: CityRepository::class)]
class City implements \Stringable
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
private $id;
#[ORM\Column(type: 'string', length: 255)]
private ?string $name = null;
#[ORM\Column(type: 'text', nullable: true)]
private ?string $description = null;
#[ORM\OneToMany(targetEntity: CityRegion::class, mappedBy: 'city')]
private \Doctrine\Common\Collections\Collection|array $regions;
#[ORM\OneToMany(targetEntity: Departement::class, mappedBy: 'city')]
private \Doctrine\Common\Collections\Collection|array $departements;
#[ORM\OneToMany(targetEntity: CustomerAddress::class, mappedBy: 'city')]
private \Doctrine\Common\Collections\Collection|array $customerAddresses;
#[ORM\ManyToMany(targetEntity: StepType::class, mappedBy: 'excludeCities')]
private Collection $stepTypes;
#[ORM\OneToMany(mappedBy: 'city', targetEntity: Store::class, orphanRemoval: true)]
private Collection $stores;
#[ORM\Column(length: 255, nullable: true)]
private ?string $cityCode = null;
#[ORM\Column(nullable: true)]
private ?array $metaData = [];
public function __toString(): string
{
return (string) $this->name;
}
public function __construct()
{
$this->regions = new ArrayCollection();
$this->departements = new ArrayCollection();
$this->customerAddresses = new ArrayCollection();
$this->stepTypes = new ArrayCollection();
$this->stores = 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 getDescription(): ?string
{
return $this->description;
}
public function setDescription(?string $description): self
{
$this->description = $description;
return $this;
}
/**
* @return Collection|CityRegion[]
*/
public function getRegions(): Collection
{
return $this->regions;
}
public function addRegion(CityRegion $region): self
{
if (!$this->regions->contains($region)) {
$this->regions[] = $region;
$region->setCity($this);
}
return $this;
}
public function removeRegion(CityRegion $region): self
{
if ($this->regions->removeElement($region)) {
// set the owning side to null (unless already changed)
if ($region->getCity() === $this) {
$region->setCity(null);
}
}
return $this;
}
/**
* @return Collection|Departement[]
*/
public function getDepartements(): Collection
{
return $this->departements;
}
public function addDepartement(Departement $departement): self
{
if (!$this->departements->contains($departement)) {
$this->departements[] = $departement;
$departement->setCity($this);
}
return $this;
}
public function removeDepartement(Departement $departement): self
{
if ($this->departements->removeElement($departement)) {
// set the owning side to null (unless already changed)
if ($departement->getCity() === $this) {
$departement->setCity(null);
}
}
return $this;
}
/**
* @return Collection<int, CustomerAddress>
*/
public function getCustomerAddresses(): Collection
{
return $this->customerAddresses;
}
public function addCustomerAddress(CustomerAddress $customerAddress): self
{
if (!$this->customerAddresses->contains($customerAddress)) {
$this->customerAddresses[] = $customerAddress;
$customerAddress->setCity($this);
}
return $this;
}
public function removeCustomerAddress(CustomerAddress $customerAddress): self
{
if ($this->customerAddresses->removeElement($customerAddress)) {
// set the owning side to null (unless already changed)
if ($customerAddress->getCity() === $this) {
$customerAddress->setCity(null);
}
}
return $this;
}
/**
* @return Collection<int, StepType>
*/
public function getStepTypes(): Collection
{
return $this->stepTypes;
}
public function addStepType(StepType $stepType): self
{
if (!$this->stepTypes->contains($stepType)) {
$this->stepTypes->add($stepType);
$stepType->addExcludeCity($this);
}
return $this;
}
public function removeStepType(StepType $stepType): self
{
if ($this->stepTypes->removeElement($stepType)) {
$stepType->removeExcludeCity($this);
}
return $this;
}
/**
* @return Collection<int, Store>
*/
public function getStores(): Collection
{
return $this->stores;
}
public function addStore(Store $store): self
{
if (!$this->stores->contains($store)) {
$this->stores->add($store);
$store->setCity($this);
}
return $this;
}
public function removeStore(Store $store): self
{
if ($this->stores->removeElement($store)) {
// set the owning side to null (unless already changed)
if ($store->getCity() === $this) {
$store->setCity(null);
}
}
return $this;
}
public function getCityCode(): ?string
{
return $this->cityCode;
}
public function setCityCode(?string $cityCode): static
{
$this->cityCode = $cityCode;
return $this;
}
public function getMetaData(): ?array
{
return $this->metaData;
}
public function setMetaData(?array $metaData): static
{
$this->metaData = $metaData;
return $this;
}
}