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

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