src/Flexy/ShopBundle/Entity/Shipping/CityRegion.php line 25

  1. <?php
  2. namespace App\Flexy\ShopBundle\Entity\Shipping;
  3. use ApiPlatform\Core\Annotation\ApiResource;
  4. use App\Flexy\ShopBundle\Entity\Order\Order;
  5. use App\Flexy\ShopBundle\Entity\Store\Store;
  6. use App\Flexy\ShopBundle\Entity\Vendor\Vendor;
  7. use App\Flexy\ShopBundle\Repository\Shipping\CityRegionRepository;
  8. use Doctrine\Common\Collections\ArrayCollection;
  9. use Doctrine\Common\Collections\Collection;
  10. use Doctrine\ORM\Mapping as ORM;
  11. use Symfony\Component\Serializer\Annotation\Groups;
  12. use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\BooleanFilter;
  13. use ApiPlatform\Core\Annotation\ApiFilter;
  14. use CrEOF\Spatial\PHP\Types\Geometry\Polygon;
  15. #[ApiResource(
  16.     normalizationContext: ['groups' => ['read']],
  17.     denormalizationContext: ['groups' => ['write']],
  18. )]
  19. #[ApiFilter(BooleanFilter::class, properties: ['isActive'])]
  20. #[ORM\Entity(repositoryClassCityRegionRepository::class)]
  21. class CityRegion implements \Stringable
  22. {
  23.     #[ORM\Id]
  24.     #[ORM\GeneratedValue]
  25.     #[ORM\Column(type'integer')]
  26.     #[Groups(["read","write"])]
  27.     private $id;
  28.     #[ORM\Column(type'string'length255)]
  29.     #[Groups(["read","write"])]
  30.     private ?string $name null;
  31.     #[ORM\Column(type'text'nullabletrue)]
  32.     #[Groups(["read","write"])]
  33.     private ?string $description null;
  34.     #[ORM\Column(type'boolean'nullabletrue)]
  35.     private $isDefault;
  36.     
  37.     #[ORM\Column(type'boolean'nullabletrue)]
  38.     private $isActive;
  39.     #[ORM\ManyToOne(targetEntityCity::class, inversedBy'regions')]
  40.     private ?\App\Flexy\ShopBundle\Entity\Shipping\City $city null;
  41.     #[ORM\Column(type'string'length255nullabletrue)]
  42.     private ?string $color null;
  43.     #[ORM\Column(type'string'length255nullabletrue)]
  44.     private $type;
  45.         #[ORM\Column(type'string'length255nullabletrue)]
  46.     private $zipCode;
  47.     #[ORM\Column(type'string'length255nullabletrue)]
  48.     private $regionCode;
  49.     #[ORM\Column(type'string'length255nullabletrue)]
  50.     #[Groups(["read","write"])]
  51.     private $lng;
  52.     #[ORM\Column(type'string'length255nullabletrue)]
  53.     #[Groups(["read","write"])]
  54.     private $lat;
  55.     #[ORM\ManyToMany(targetEntityShippingMethod::class, mappedBy'cityRegions')]
  56.     private \Doctrine\Common\Collections\Collection|array $shippingMethods;
  57.     #[ORM\ManyToOne(targetEntityVendor::class)]
  58.     private $vendor;
  59.     #[ORM\OneToMany(targetEntityOrder::class, mappedBy'cityRegion')]
  60.     private \Doctrine\Common\Collections\Collection|array $orders;
  61.         #[ORM\OneToMany(targetEntityOrder::class, mappedBy'cityRegionCollect')]
  62.     private \Doctrine\Common\Collections\Collection|array $collectedOrders ;
  63.     #[ORM\OneToMany(targetEntityShipmentItem::class, mappedBy'shippingCityRegion')]
  64.     private \Doctrine\Common\Collections\Collection|array $shipmentItemsShipped;
  65.      #[ORM\OneToMany(targetEntityShipmentItem::class, mappedBy'collectCityRegion')]
  66.     private \Doctrine\Common\Collections\Collection|array $shipmentItemsCollected ;
  67.      #[ORM\OneToMany(mappedBy'�cityRegion'targetEntityStore::class)]
  68.      private Collection $stores;
  69.      #[ORM\OneToMany(mappedBy'collectCityRegion'targetEntityShipment::class,cascade:["remove"])]
  70.      #[ORM\JoinColumn(name"collect_city_region_id"referencedColumnName"id"onDelete"SET NULL")]
  71.      private Collection $collectedShipments;
  72.      #[ORM\OneToMany(mappedBy'shippingCityRegion'targetEntityShipment::class,cascade:["remove"])]
  73.      #[ORM\JoinColumn(name"shipping_city_region_id"referencedColumnName"id"onDelete"SET NULL")]
  74.      private Collection $shippedShipments;
  75.      #[ORM\ManyToMany(targetEntityVendor::class, mappedBy'cityRegions')]
  76.      private Collection $vendors;
  77.      #[ORM\Column(type'polygon'nullabletrue)]
  78.      private $geoJson null;
  79.      #[ORM\Column(nullabletrue)]
  80.      private ?array $metaData = [];
  81.     
  82.     
  83.     public function __construct()
  84.     {
  85.         $this->shippingMethods = new ArrayCollection();
  86.         $this->orders = new ArrayCollection();
  87.         $this->stores = new ArrayCollection();
  88.         $this->collectedShipments = new ArrayCollection();
  89.         $this->shippedShipments = new ArrayCollection();
  90.         $this->vendors = new ArrayCollection();
  91.     }
  92.     public function __toString(): string
  93.     {
  94.         return (string)$this->name;
  95.     }
  96.     public function getId(): ?int
  97.     {
  98.         return $this->id;
  99.     }
  100.     public function getName(): ?string
  101.     {
  102.         return $this->name;
  103.     }
  104.     public function setName(string $name): self
  105.     {
  106.         $this->name $name;
  107.         return $this;
  108.     }
  109.     public function getDescription(): ?string
  110.     {
  111.         return $this->description;
  112.     }
  113.     public function setDescription(?string $description): self
  114.     {
  115.         $this->description $description;
  116.         return $this;
  117.     }
  118.     public function getCity(): ?City
  119.     {
  120.         return $this->city;
  121.     }
  122.     public function setCity(?City $city): self
  123.     {
  124.         $this->city $city;
  125.         return $this;
  126.     }
  127.     public function getColor(): ?string
  128.     {
  129.         return $this->color;
  130.     }
  131.     public function setColor(?string $color): self
  132.     {
  133.         $this->color $color;
  134.         return $this;
  135.     }
  136.     /**
  137.      * @return Collection<int, ShippingMethod>
  138.      */
  139.     public function getShippingMethods(): Collection
  140.     {
  141.         return $this->shippingMethods;
  142.     }
  143.     public function addShippingMethod(ShippingMethod $shippingMethod): self
  144.     {
  145.         if (!$this->shippingMethods->contains($shippingMethod)) {
  146.             $this->shippingMethods[] = $shippingMethod;
  147.         }
  148.         return $this;
  149.     }
  150.     public function removeShippingMethod(ShippingMethod $shippingMethod): self
  151.     {
  152.         $this->shippingMethods->removeElement($shippingMethod);
  153.         return $this;
  154.     }
  155.     /**
  156.      * @return Collection<int, Order>
  157.      */
  158.     public function getOrders(): Collection
  159.     {
  160.         return $this->orders;
  161.     }
  162.     public function addOrder(Order $order): self
  163.     {
  164.         if (!$this->orders->contains($order)) {
  165.             $this->orders[] = $order;
  166.             $order->setCityRegionCollect($this);
  167.         }
  168.         return $this;
  169.     }
  170.     public function removeOrder(Order $order): self
  171.     {
  172.         if ($this->orders->removeElement($order)) {
  173.             // set the owning side to null (unless already changed)
  174.             if ($order->getCityRegionCollect() === $this) {
  175.                 $order->setCityRegionCollect(null);
  176.             }
  177.         }
  178.         return $this;
  179.     }
  180.         /**
  181.      * @return Collection<int, Order>
  182.      */
  183.     public function getCollectedOrders(): Collection
  184.     {
  185.         return $this->collectedOrders;
  186.     }
  187.     public function addCollectedOrder(Order $collectedOrder): self
  188.     {
  189.         if (!$this->collectedOrders->contains($collectedOrder)) {
  190.             $this->collectedOrders[] = $collectedOrder;
  191.             $collectedOrder->setCityRegionCollect($this);
  192.         }
  193.         return $this;
  194.     }
  195.     public function removeCollectedOrder(Order $collectedOrder): self
  196.     {
  197.         if ($this->collectedOrders->removeElement($collectedOrder)) {
  198.             // set the owning side to null (unless already changed)
  199.             if ($collectedOrder->getCityRegionCollect() === $this) {
  200.                 $collectedOrder->setCityRegionCollect(null);
  201.             }
  202.         }
  203.         return $this;
  204.     }
  205.                 /**
  206.      * @return Collection<int, ShipmentItem>
  207.      */
  208.     public function getShipmentItemsCollected(): Collection
  209.     {
  210.         return $this->shipmentItemsCollected;
  211.     }
  212.     public function addShipmentItemCollected(ShipmentItem $shipmentItemCollected): self
  213.     {
  214.         if (!$this->shipmentItemsCollected->contains($shipmentItemCollected)) {
  215.             $this->shipmentItemsCollected[] = $shipmentItemCollected;
  216.             $shipmentItemCollected->setCollectCityRegion($this);
  217.         }
  218.         return $this;
  219.     }
  220.     public function removeShipmentItemCollected(ShipmentItem $shipmentItemCollected): self
  221.     {
  222.         if ($this->shipmentItemsCollected->removeElement($shipmentItemCollected)) {
  223.             // set the owning side to null (unless already changed)
  224.             if ($shipmentItemCollected->getCollectCityRegion() === $this) {
  225.                 $shipmentItemCollected->setCollectCityRegion(null);
  226.             }
  227.         }
  228.         return $this;
  229.     }
  230.             /**
  231.      * @return Collection<int, ShipmentItem>
  232.      */
  233.     public function getShipmentItemsShipped(): Collection
  234.     {
  235.         return $this->shipmentItemsShipped;
  236.     }
  237.     public function addShipmentItemShipped(ShipmentItem $shipmentItemShipped): self
  238.     {
  239.         if (!$this->shipmentItemsShipped->contains($shipmentItemShipped)) {
  240.             $this->shipmentItemsShipped[] = $shipmentItemShipped;
  241.             $shipmentItemShipped->setShippingCityRegion($this);
  242.         }
  243.         return $this;
  244.     }
  245.     public function removeShipmentItemShipped(ShipmentItem $shipmentItemShipped): self
  246.     {
  247.         if ($this->shipmentItemsShipped->removeElement($shipmentItemShipped)) {
  248.             // set the owning side to null (unless already changed)
  249.             if ($shipmentItemShipped->getShippingCityRegion() === $this) {
  250.                 $shipmentItemShipped->setShippingCityRegion(null);
  251.             }
  252.         }
  253.         return $this;
  254.     }
  255.     /**
  256.      * Get the value of lng
  257.      */ 
  258.     public function getLng()
  259.     {
  260.         return $this->lng;
  261.     }
  262.     /**
  263.      * Set the value of lng
  264.      *
  265.      * @return  self
  266.      */ 
  267.     public function setLng($lng)
  268.     {
  269.         $this->lng $lng;
  270.         return $this;
  271.     }
  272.     /**
  273.      * Get the value of lat
  274.      */ 
  275.     public function getLat()
  276.     {
  277.         return $this->lat;
  278.     }
  279.     /**
  280.      * Set the value of lat
  281.      *
  282.      * @return  self
  283.      */ 
  284.     public function setLat($lat)
  285.     {
  286.         $this->lat $lat;
  287.         return $this;
  288.     }
  289.     /**
  290.      * Get the value of type
  291.      */ 
  292.     public function getType()
  293.     {
  294.         return $this->type;
  295.     }
  296.     /**
  297.      * Set the value of type
  298.      *
  299.      * @return  self
  300.      */ 
  301.     public function setType($type)
  302.     {
  303.         $this->type $type;
  304.         return $this;
  305.     }
  306.     /**
  307.      * Get the value of zipCode
  308.      */ 
  309.     public function getZipCode()
  310.     {
  311.         return $this->zipCode;
  312.     }
  313.     /**
  314.      * Set the value of zipCode
  315.      *
  316.      * @return  self
  317.      */ 
  318.     public function setZipCode($zipCode)
  319.     {
  320.         $this->zipCode $zipCode;
  321.         return $this;
  322.     }
  323.     /**
  324.      * Get the value of regionCode
  325.      */ 
  326.     public function getRegionCode()
  327.     {
  328.         return $this->regionCode;
  329.     }
  330.     /**
  331.      * Set the value of regionCode
  332.      *
  333.      * @return  self
  334.      */ 
  335.     public function setRegionCode($regionCode)
  336.     {
  337.         $this->regionCode $regionCode;
  338.         return $this;
  339.     }
  340.     /**
  341.      * Get the value of vendor
  342.      */ 
  343.     public function getVendor()
  344.     {
  345.         return $this->vendor;
  346.     }
  347.     /**
  348.      * Set the value of vendor
  349.      *
  350.      * @return  self
  351.      */ 
  352.     public function setVendor($vendor)
  353.     {
  354.         $this->vendor $vendor;
  355.         return $this;
  356.     }
  357.     /**
  358.      * Get the value of isDefault
  359.      */ 
  360.     public function getIsDefault()
  361.     {
  362.         return $this->isDefault;
  363.     }
  364.     /**
  365.      * Set the value of isDefault
  366.      *
  367.      * @return  self
  368.      */ 
  369.     public function setIsDefault($isDefault)
  370.     {
  371.         $this->isDefault $isDefault;
  372.         return $this;
  373.     }
  374.     /**
  375.      * Get the value of isActive
  376.      */ 
  377.     public function getIsActive()
  378.     {
  379.         return $this->isActive;
  380.     }
  381.     /**
  382.      * Set the value of isActive
  383.      *
  384.      * @return  self
  385.      */ 
  386.     public function setIsActive($isActive)
  387.     {
  388.         $this->isActive $isActive;
  389.         return $this;
  390.     }
  391.     /**
  392.      * @return Collection<int, Store>
  393.      */
  394.     public function getStores(): Collection
  395.     {
  396.         return $this->stores;
  397.     }
  398.     public function addStore(Store $store): self
  399.     {
  400.         if (!$this->stores->contains($store)) {
  401.             $this->stores->add($store);
  402.             $store->setCityRegion($this);
  403.         }
  404.         return $this;
  405.     }
  406.     public function removeStore(Store $store): self
  407.     {
  408.         if ($this->stores->removeElement($store)) {
  409.             // set the owning side to null (unless already changed)
  410.             if ($store->getCityRegion() === $this) {
  411.                 $store->setCityRegion(null);
  412.             }
  413.         }
  414.         return $this;
  415.     }
  416.     /**
  417.      * @return Collection<int, Shipment>
  418.      */
  419.     public function getCollectedShipments(): Collection
  420.     {
  421.         return $this->collectedShipments;
  422.     }
  423.     public function addCollectedShipment(Shipment $collectedShipment): self
  424.     {
  425.         if (!$this->collectedShipments->contains($collectedShipment)) {
  426.             $this->collectedShipments->add($collectedShipment);
  427.             $collectedShipment->setCollectCityRegion($this);
  428.         }
  429.         return $this;
  430.     }
  431.     public function removeCollectedShipment(Shipment $collectedShipment): self
  432.     {
  433.         if ($this->collectedShipments->removeElement($collectedShipment)) {
  434.             // set the owning side to null (unless already changed)
  435.             if ($collectedShipment->getCollectCityRegion() === $this) {
  436.                 $collectedShipment->setCollectCityRegion(null);
  437.             }
  438.         }
  439.         return $this;
  440.     }
  441.     /**
  442.      * @return Collection<int, Shipment>
  443.      */
  444.     public function getShippedShipments(): Collection
  445.     {
  446.         return $this->shippedShipments;
  447.     }
  448.     public function addShippedShipment(Shipment $shippedShipment): self
  449.     {
  450.         if (!$this->shippedShipments->contains($shippedShipment)) {
  451.             $this->shippedShipments->add($shippedShipment);
  452.             $shippedShipment->setShippingCityRegion($this);
  453.         }
  454.         return $this;
  455.     }
  456.     public function removeShippedShipment(Shipment $shippedShipment): self
  457.     {
  458.         if ($this->shippedShipments->removeElement($shippedShipment)) {
  459.             // set the owning side to null (unless already changed)
  460.             if ($shippedShipment->getShippingCityRegion() === $this) {
  461.                 $shippedShipment->setShippingCityRegion(null);
  462.             }
  463.         }
  464.         return $this;
  465.     }
  466.     /**
  467.      * @return Collection<int, Vendor>
  468.      */
  469.     public function getVendors(): Collection
  470.     {
  471.         return $this->vendors;
  472.     }
  473.     public function addVendor(Vendor $vendor): self
  474.     {
  475.         if (!$this->vendors->contains($vendor)) {
  476.             $this->vendors->add($vendor);
  477.             $vendor->addCityRegion($this);
  478.         }
  479.         return $this;
  480.     }
  481.     public function removeVendor(Vendor $vendor): self
  482.     {
  483.         if ($this->vendors->removeElement($vendor)) {
  484.             $vendor->removeCityRegion($this);
  485.         }
  486.         return $this;
  487.     }
  488.     public function getGeoJson(): ?Polygon
  489.     {
  490.         return $this->geoJson;
  491.     }
  492.     public function setGeoJson(?Polygon $geoJson): self
  493.     {
  494.         $this->geoJson $geoJson;
  495.         return $this;
  496.     }
  497.     public function getMetaData(): ?array
  498.     {
  499.         return $this->metaData;
  500.     }
  501.     public function setMetaData(?array $metaData): static
  502.     {
  503.         $this->metaData $metaData;
  504.         return $this;
  505.     }
  506. }