src/Flexy/ShopBundle/Entity/Shipping/CityRegion.php line 25
<?php
namespace App\Flexy\ShopBundle\Entity\Shipping;
use ApiPlatform\Core\Annotation\ApiResource;
use App\Flexy\ShopBundle\Entity\Order\Order;
use App\Flexy\ShopBundle\Entity\Store\Store;
use App\Flexy\ShopBundle\Entity\Vendor\Vendor;
use App\Flexy\ShopBundle\Repository\Shipping\CityRegionRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;
use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\BooleanFilter;
use ApiPlatform\Core\Annotation\ApiFilter;
use CrEOF\Spatial\PHP\Types\Geometry\Polygon;
#[ApiResource(
normalizationContext: ['groups' => ['read']],
denormalizationContext: ['groups' => ['write']],
)]
#[ApiFilter(BooleanFilter::class, properties: ['isActive'])]
#[ORM\Entity(repositoryClass: CityRegionRepository::class)]
class CityRegion implements \Stringable
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
#[Groups(["read","write"])]
private $id;
#[ORM\Column(type: 'string', length: 255)]
#[Groups(["read","write"])]
private ?string $name = null;
#[ORM\Column(type: 'text', nullable: true)]
#[Groups(["read","write"])]
private ?string $description = null;
#[ORM\Column(type: 'boolean', nullable: true)]
private $isDefault;
#[ORM\Column(type: 'boolean', nullable: true)]
private $isActive;
#[ORM\ManyToOne(targetEntity: City::class, inversedBy: 'regions')]
private ?\App\Flexy\ShopBundle\Entity\Shipping\City $city = null;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private ?string $color = null;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private $type;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private $zipCode;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private $regionCode;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
#[Groups(["read","write"])]
private $lng;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
#[Groups(["read","write"])]
private $lat;
#[ORM\ManyToMany(targetEntity: ShippingMethod::class, mappedBy: 'cityRegions')]
private \Doctrine\Common\Collections\Collection|array $shippingMethods;
#[ORM\ManyToOne(targetEntity: Vendor::class)]
private $vendor;
#[ORM\OneToMany(targetEntity: Order::class, mappedBy: 'cityRegion')]
private \Doctrine\Common\Collections\Collection|array $orders;
#[ORM\OneToMany(targetEntity: Order::class, mappedBy: 'cityRegionCollect')]
private \Doctrine\Common\Collections\Collection|array $collectedOrders ;
#[ORM\OneToMany(targetEntity: ShipmentItem::class, mappedBy: 'shippingCityRegion')]
private \Doctrine\Common\Collections\Collection|array $shipmentItemsShipped;
#[ORM\OneToMany(targetEntity: ShipmentItem::class, mappedBy: 'collectCityRegion')]
private \Doctrine\Common\Collections\Collection|array $shipmentItemsCollected ;
#[ORM\OneToMany(mappedBy: '�cityRegion', targetEntity: Store::class)]
private Collection $stores;
#[ORM\OneToMany(mappedBy: 'collectCityRegion', targetEntity: Shipment::class,cascade:["remove"])]
#[ORM\JoinColumn(name: "collect_city_region_id", referencedColumnName: "id", onDelete: "SET NULL")]
private Collection $collectedShipments;
#[ORM\OneToMany(mappedBy: 'shippingCityRegion', targetEntity: Shipment::class,cascade:["remove"])]
#[ORM\JoinColumn(name: "shipping_city_region_id", referencedColumnName: "id", onDelete: "SET NULL")]
private Collection $shippedShipments;
#[ORM\ManyToMany(targetEntity: Vendor::class, mappedBy: 'cityRegions')]
private Collection $vendors;
#[ORM\Column(type: 'polygon', nullable: true)]
private $geoJson = null;
#[ORM\Column(nullable: true)]
private ?array $metaData = [];
public function __construct()
{
$this->shippingMethods = new ArrayCollection();
$this->orders = new ArrayCollection();
$this->stores = new ArrayCollection();
$this->collectedShipments = new ArrayCollection();
$this->shippedShipments = new ArrayCollection();
$this->vendors = new ArrayCollection();
}
public function __toString(): string
{
return (string)$this->name;
}
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;
}
public function getCity(): ?City
{
return $this->city;
}
public function setCity(?City $city): self
{
$this->city = $city;
return $this;
}
public function getColor(): ?string
{
return $this->color;
}
public function setColor(?string $color): self
{
$this->color = $color;
return $this;
}
/**
* @return Collection<int, ShippingMethod>
*/
public function getShippingMethods(): Collection
{
return $this->shippingMethods;
}
public function addShippingMethod(ShippingMethod $shippingMethod): self
{
if (!$this->shippingMethods->contains($shippingMethod)) {
$this->shippingMethods[] = $shippingMethod;
}
return $this;
}
public function removeShippingMethod(ShippingMethod $shippingMethod): self
{
$this->shippingMethods->removeElement($shippingMethod);
return $this;
}
/**
* @return Collection<int, Order>
*/
public function getOrders(): Collection
{
return $this->orders;
}
public function addOrder(Order $order): self
{
if (!$this->orders->contains($order)) {
$this->orders[] = $order;
$order->setCityRegionCollect($this);
}
return $this;
}
public function removeOrder(Order $order): self
{
if ($this->orders->removeElement($order)) {
// set the owning side to null (unless already changed)
if ($order->getCityRegionCollect() === $this) {
$order->setCityRegionCollect(null);
}
}
return $this;
}
/**
* @return Collection<int, Order>
*/
public function getCollectedOrders(): Collection
{
return $this->collectedOrders;
}
public function addCollectedOrder(Order $collectedOrder): self
{
if (!$this->collectedOrders->contains($collectedOrder)) {
$this->collectedOrders[] = $collectedOrder;
$collectedOrder->setCityRegionCollect($this);
}
return $this;
}
public function removeCollectedOrder(Order $collectedOrder): self
{
if ($this->collectedOrders->removeElement($collectedOrder)) {
// set the owning side to null (unless already changed)
if ($collectedOrder->getCityRegionCollect() === $this) {
$collectedOrder->setCityRegionCollect(null);
}
}
return $this;
}
/**
* @return Collection<int, ShipmentItem>
*/
public function getShipmentItemsCollected(): Collection
{
return $this->shipmentItemsCollected;
}
public function addShipmentItemCollected(ShipmentItem $shipmentItemCollected): self
{
if (!$this->shipmentItemsCollected->contains($shipmentItemCollected)) {
$this->shipmentItemsCollected[] = $shipmentItemCollected;
$shipmentItemCollected->setCollectCityRegion($this);
}
return $this;
}
public function removeShipmentItemCollected(ShipmentItem $shipmentItemCollected): self
{
if ($this->shipmentItemsCollected->removeElement($shipmentItemCollected)) {
// set the owning side to null (unless already changed)
if ($shipmentItemCollected->getCollectCityRegion() === $this) {
$shipmentItemCollected->setCollectCityRegion(null);
}
}
return $this;
}
/**
* @return Collection<int, ShipmentItem>
*/
public function getShipmentItemsShipped(): Collection
{
return $this->shipmentItemsShipped;
}
public function addShipmentItemShipped(ShipmentItem $shipmentItemShipped): self
{
if (!$this->shipmentItemsShipped->contains($shipmentItemShipped)) {
$this->shipmentItemsShipped[] = $shipmentItemShipped;
$shipmentItemShipped->setShippingCityRegion($this);
}
return $this;
}
public function removeShipmentItemShipped(ShipmentItem $shipmentItemShipped): self
{
if ($this->shipmentItemsShipped->removeElement($shipmentItemShipped)) {
// set the owning side to null (unless already changed)
if ($shipmentItemShipped->getShippingCityRegion() === $this) {
$shipmentItemShipped->setShippingCityRegion(null);
}
}
return $this;
}
/**
* Get the value of lng
*/
public function getLng()
{
return $this->lng;
}
/**
* Set the value of lng
*
* @return self
*/
public function setLng($lng)
{
$this->lng = $lng;
return $this;
}
/**
* Get the value of lat
*/
public function getLat()
{
return $this->lat;
}
/**
* Set the value of lat
*
* @return self
*/
public function setLat($lat)
{
$this->lat = $lat;
return $this;
}
/**
* Get the value of type
*/
public function getType()
{
return $this->type;
}
/**
* Set the value of type
*
* @return self
*/
public function setType($type)
{
$this->type = $type;
return $this;
}
/**
* Get the value of zipCode
*/
public function getZipCode()
{
return $this->zipCode;
}
/**
* Set the value of zipCode
*
* @return self
*/
public function setZipCode($zipCode)
{
$this->zipCode = $zipCode;
return $this;
}
/**
* Get the value of regionCode
*/
public function getRegionCode()
{
return $this->regionCode;
}
/**
* Set the value of regionCode
*
* @return self
*/
public function setRegionCode($regionCode)
{
$this->regionCode = $regionCode;
return $this;
}
/**
* Get the value of vendor
*/
public function getVendor()
{
return $this->vendor;
}
/**
* Set the value of vendor
*
* @return self
*/
public function setVendor($vendor)
{
$this->vendor = $vendor;
return $this;
}
/**
* Get the value of isDefault
*/
public function getIsDefault()
{
return $this->isDefault;
}
/**
* Set the value of isDefault
*
* @return self
*/
public function setIsDefault($isDefault)
{
$this->isDefault = $isDefault;
return $this;
}
/**
* Get the value of isActive
*/
public function getIsActive()
{
return $this->isActive;
}
/**
* Set the value of isActive
*
* @return self
*/
public function setIsActive($isActive)
{
$this->isActive = $isActive;
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->setCityRegion($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->getCityRegion() === $this) {
$store->setCityRegion(null);
}
}
return $this;
}
/**
* @return Collection<int, Shipment>
*/
public function getCollectedShipments(): Collection
{
return $this->collectedShipments;
}
public function addCollectedShipment(Shipment $collectedShipment): self
{
if (!$this->collectedShipments->contains($collectedShipment)) {
$this->collectedShipments->add($collectedShipment);
$collectedShipment->setCollectCityRegion($this);
}
return $this;
}
public function removeCollectedShipment(Shipment $collectedShipment): self
{
if ($this->collectedShipments->removeElement($collectedShipment)) {
// set the owning side to null (unless already changed)
if ($collectedShipment->getCollectCityRegion() === $this) {
$collectedShipment->setCollectCityRegion(null);
}
}
return $this;
}
/**
* @return Collection<int, Shipment>
*/
public function getShippedShipments(): Collection
{
return $this->shippedShipments;
}
public function addShippedShipment(Shipment $shippedShipment): self
{
if (!$this->shippedShipments->contains($shippedShipment)) {
$this->shippedShipments->add($shippedShipment);
$shippedShipment->setShippingCityRegion($this);
}
return $this;
}
public function removeShippedShipment(Shipment $shippedShipment): self
{
if ($this->shippedShipments->removeElement($shippedShipment)) {
// set the owning side to null (unless already changed)
if ($shippedShipment->getShippingCityRegion() === $this) {
$shippedShipment->setShippingCityRegion(null);
}
}
return $this;
}
/**
* @return Collection<int, Vendor>
*/
public function getVendors(): Collection
{
return $this->vendors;
}
public function addVendor(Vendor $vendor): self
{
if (!$this->vendors->contains($vendor)) {
$this->vendors->add($vendor);
$vendor->addCityRegion($this);
}
return $this;
}
public function removeVendor(Vendor $vendor): self
{
if ($this->vendors->removeElement($vendor)) {
$vendor->removeCityRegion($this);
}
return $this;
}
public function getGeoJson(): ?Polygon
{
return $this->geoJson;
}
public function setGeoJson(?Polygon $geoJson): self
{
$this->geoJson = $geoJson;
return $this;
}
public function getMetaData(): ?array
{
return $this->metaData;
}
public function setMetaData(?array $metaData): static
{
$this->metaData = $metaData;
return $this;
}
}