src/Flexy/ShopBundle/Entity/Shipping/ShipmentItem.php line 16

  1. <?php
  2. namespace App\Flexy\ShopBundle\Entity\Shipping;
  3. use ApiPlatform\Core\Annotation\ApiResource;
  4. use App\Flexy\ShopBundle\Entity\Order\OrderItem;
  5. use App\Flexy\ShopBundle\Repository\Shipping\ShipmentItemRepository;
  6. use Doctrine\Common\Collections\ArrayCollection;
  7. use Doctrine\Common\Collections\Collection;
  8. use Doctrine\DBAL\Types\Types;
  9. use Doctrine\ORM\Mapping as ORM;
  10. use Symfony\Component\Validator\Constraints as Assert;
  11. #[ApiResource]
  12. #[ORM\Entity(repositoryClassShipmentItemRepository::class)]
  13. class ShipmentItem implements \Stringable
  14. {
  15.     #[ORM\Id]
  16.     #[ORM\GeneratedValue]
  17.     #[ORM\Column(type'integer')]
  18.     private $id;
  19.     #[ORM\Column(type'datetime_immutable'nullabletrue)]
  20.     private ?\DateTimeImmutable $createdAt null;
  21.     #[ORM\Column(type'boolean'nullabletrue)]
  22.     private ?bool $isShippable null;
  23.     #[ORM\Column(type'string'length255nullabletrue)]
  24.     #[Assert\NotNull]
  25.     #[Assert\NotBlank]
  26.     #[Assert\Regex(pattern'/[a-zA-Z0-9,.]/'message'Address must be alphanumeric')]
  27.     private $collectAddress;
  28.         #[ORM\Column(type'string'length255nullabletrue)]
  29.     private $collectAddressIndication;
  30.     #[ORM\Column(type'string'length255nullabletrue)]
  31.     private $collectLng;
  32.         #[ORM\Column(type'string'length255nullabletrue)]
  33.     private $collectLat;
  34.     #[ORM\Column(type'string'length255nullabletrue)]
  35.     private $collectAddressPhone;
  36.     #[ORM\Column(type'string'length255nullabletrue)]
  37.     #[Assert\NotNull]
  38.     #[Assert\NotBlank]
  39.     #[Assert\Regex(pattern'/[a-zA-Z0-9,.]/'message'Address must be alphanumeric')]
  40.     private $shippingAddress;
  41.     #[ORM\Column(type'string'length255nullabletrue)]
  42.     private $shippingAddressIndication;
  43.         #[ORM\Column(type'string'length255nullabletrue)]
  44.     private $shippingLng;
  45.             #[ORM\Column(type'string'length255nullabletrue)]
  46.     private $shippingLat;
  47.     #[ORM\Column(type'string'length255nullabletrue)]
  48.     private $shippingPhone;
  49.     #[ORM\Column(typeTypes::DATE_MUTABLEnullabletrue)]
  50.     private ?\DateTimeInterface $collectDate null;
  51.     #[ORM\Column(typeTypes::TIME_MUTABLEnullabletrue)]
  52.     private ?\DateTimeInterface $collectTime null;
  53.     #[ORM\Column(typeTypes::DATE_MUTABLEnullabletrue)]
  54.     private ?\DateTimeInterface $shippingDate null;
  55.     #[ORM\Column(typeTypes::TIME_MUTABLEnullabletrue)]
  56.     private ?\DateTimeInterface $shippingTime null;
  57.     #[ORM\ManyToOne(targetEntityCityRegion::class, inversedBy'shipmentItemsShipped')]
  58.     #[ORM\JoinColumn(nullabletrue)]
  59.     private $shippingCityRegion;
  60.     #[ORM\ManyToOne(targetEntityCityRegion::class, inversedBy'shipmentItemsCollected')]
  61.     #[ORM\JoinColumn(nullabletrue)]
  62.     private $collectCityRegion;
  63.     #[ORM\ManyToOne(targetEntityShipment::class, inversedBy'shipmentItems',cascade:["persist"])]
  64.     private ?\App\Flexy\ShopBundle\Entity\Shipping\Shipment $shipment null;
  65.     #[ORM\OneToOne(targetEntityOrderItem::class, mappedBy'shipmentItem'cascade: ['persist'])]
  66.     private $orderItem;
  67.     #[ORM\Column(nullabletrue)]
  68.     private ?int $quantity null;
  69.     #[ORM\OneToMany(mappedBy'shipmentItem'targetEntityShipmentItemChild::class)]
  70.     private Collection $shipmentItemChildren;
  71.     #[ORM\Column(nullabletrue)]
  72.     private ?float $weight null;
  73.     #[ORM\ManyToOne(inversedBy'shipmentItems')]
  74.     private ?ShipmentItemType $shipmentItemType null;
  75.     public function __construct()
  76.     {
  77.         $this->shipmentItemChildren = new ArrayCollection();
  78.         
  79.        
  80.     }
  81.     public function getId(): ?int
  82.     {
  83.         return $this->id;
  84.     }
  85.     public function __toString(): string
  86.     {
  87.         return (string)"Shipment : ".$this->getId();
  88.     }
  89.     public function getCreatedAt(): ?\DateTimeImmutable
  90.     {
  91.         return $this->createdAt;
  92.     }
  93.     public function setCreatedAt(?\DateTimeImmutable $createdAt): self
  94.     {
  95.         $this->createdAt $createdAt;
  96.         return $this;
  97.     }
  98.     public function getIsShippable(): ?bool
  99.     {
  100.         return $this->isShippable;
  101.     }
  102.     public function setIsShippable(?bool $isShippable): self
  103.     {
  104.         $this->isShippable $isShippable;
  105.         return $this;
  106.     }
  107.     public function getShipment(): ?Shipment
  108.     {
  109.         return $this->shipment;
  110.     }
  111.     public function setShipment(?Shipment $shipment): self
  112.     {
  113.         $this->shipment $shipment;
  114.         return $this;
  115.     }
  116.     /**
  117.      * Get the value of orderItem
  118.      */ 
  119.     public function getOrderItem()
  120.     {
  121.         return $this->orderItem;
  122.     }
  123.     /**
  124.      * Set the value of orderItem
  125.      *
  126.      * @return  self
  127.      */ 
  128.     public function setOrderItem($orderItem)
  129.     {
  130.         $this->orderItem $orderItem;
  131.         return $this;
  132.     }
  133.     /**
  134.      * Get the value of collectCityRegion
  135.      */ 
  136.     public function getCollectCityRegion()
  137.     {
  138.         return $this->collectCityRegion;
  139.     }
  140.     /**
  141.      * Set the value of collectCityRegion
  142.      *
  143.      * @return  self
  144.      */ 
  145.     public function setCollectCityRegion($collectCityRegion)
  146.     {
  147.         $this->collectCityRegion $collectCityRegion;
  148.         return $this;
  149.     }
  150.     /**
  151.      * Get the value of shippingCityRegion
  152.      */ 
  153.     public function getShippingCityRegion()
  154.     {
  155.         return $this->shippingCityRegion;
  156.     }
  157.     /**
  158.      * Set the value of shippingCityRegion
  159.      *
  160.      * @return  self
  161.      */ 
  162.     public function setShippingCityRegion($shippingCityRegion)
  163.     {
  164.         $this->shippingCityRegion $shippingCityRegion;
  165.         return $this;
  166.     }
  167.     /**
  168.      * Get the value of collectAddressPhone
  169.      */ 
  170.     public function getCollectAddressPhone()
  171.     {
  172.         return $this->collectAddressPhone;
  173.     }
  174.     /**
  175.      * Set the value of collectAddressPhone
  176.      *
  177.      * @return  self
  178.      */ 
  179.     public function setCollectAddressPhone($collectAddressPhone)
  180.     {
  181.         $this->collectAddressPhone $collectAddressPhone;
  182.         return $this;
  183.     }
  184.     /**
  185.      * Get the value of collectAddressIndication
  186.      */ 
  187.     public function getCollectAddressIndication()
  188.     {
  189.         return $this->collectAddressIndication;
  190.     }
  191.     /**
  192.      * Set the value of collectAddressIndication
  193.      *
  194.      * @return  self
  195.      */ 
  196.     public function setCollectAddressIndication($collectAddressIndication)
  197.     {
  198.         $this->collectAddressIndication $collectAddressIndication;
  199.         return $this;
  200.     }
  201.     /**
  202.      * Get the value of collectAddress
  203.      */ 
  204.     public function getCollectAddress()
  205.     {
  206.         return $this->collectAddress;
  207.     }
  208.     /**
  209.      * Set the value of collectAddress
  210.      *
  211.      * @return  self
  212.      */ 
  213.     public function setCollectAddress($collectAddress)
  214.     {
  215.         $this->collectAddress $collectAddress;
  216.         return $this;
  217.     }
  218.     /**
  219.      * Get the value of shippingPhone
  220.      */ 
  221.     public function getShippingPhone()
  222.     {
  223.         return $this->shippingPhone;
  224.     }
  225.     /**
  226.      * Set the value of shippingPhone
  227.      *
  228.      * @return  self
  229.      */ 
  230.     public function setShippingPhone($shippingPhone)
  231.     {
  232.         $this->shippingPhone $shippingPhone;
  233.         return $this;
  234.     }
  235.     /**
  236.      * Get the value of shippingAdressIndication
  237.      */ 
  238.     public function getShippingAddressIndication()
  239.     {
  240.         return $this->shippingAddressIndication;
  241.     }
  242.     /**
  243.      * Set the value of shippingAdressIndication
  244.      *
  245.      * @return  self
  246.      */ 
  247.     public function setShippingAddressIndication($shippingAdressIndication)
  248.     {
  249.         $this->shippingAddressIndication $shippingAdressIndication;
  250.         return $this;
  251.     }
  252.     /**
  253.      * Get the value of shippingAdress
  254.      */ 
  255.     public function getShippingAddress()
  256.     {
  257.         return $this->shippingAddress;
  258.     }
  259.     /**
  260.      * Set the value of shippingAdress
  261.      *
  262.      * @return  self
  263.      */ 
  264.     public function setShippingAddress($shippingAdress)
  265.     {
  266.         $this->shippingAddress $shippingAdress;
  267.         return $this;
  268.     }
  269.     /**
  270.      * Get the value of shippingLng
  271.      */ 
  272.     public function getShippingLng()
  273.     {
  274.         return $this->shippingLng;
  275.     }
  276.     /**
  277.      * Set the value of shippingLng
  278.      *
  279.      * @return  self
  280.      */ 
  281.     public function setShippingLng($shippingLng)
  282.     {
  283.         $this->shippingLng $shippingLng;
  284.         return $this;
  285.     }
  286.     /**
  287.      * Get the value of collectLng
  288.      */ 
  289.     public function getCollectLng()
  290.     {
  291.         return $this->collectLng;
  292.     }
  293.     /**
  294.      * Set the value of collectLng
  295.      *
  296.      * @return  self
  297.      */ 
  298.     public function setCollectLng($collectLng)
  299.     {
  300.         $this->collectLng $collectLng;
  301.         return $this;
  302.     }
  303.     /**
  304.      * Get the value of collectLat
  305.      */ 
  306.     public function getCollectLat()
  307.     {
  308.         return $this->collectLat;
  309.     }
  310.     /**
  311.      * Set the value of collectLat
  312.      *
  313.      * @return  self
  314.      */ 
  315.     public function setCollectLat($collectLat)
  316.     {
  317.         $this->collectLat $collectLat;
  318.         return $this;
  319.     }
  320.     /**
  321.      * Get the value of shippingLat
  322.      */ 
  323.     public function getShippingLat()
  324.     {
  325.         return $this->shippingLat;
  326.     }
  327.     /**
  328.      * Set the value of shippingLat
  329.      *
  330.      * @return  self
  331.      */ 
  332.     public function setShippingLat($shippingLat)
  333.     {
  334.         $this->shippingLat $shippingLat;
  335.         return $this;
  336.     }
  337.     public function getQuantity(): ?int
  338.     {
  339.         return $this->quantity;
  340.     }
  341.     public function setQuantity(?int $quantity): self
  342.     {
  343.         $this->quantity $quantity;
  344.         return $this;
  345.     }
  346.     public function getCollectDate(): ?\DateTimeInterface
  347.     {
  348.         return $this->collectDate;
  349.     }
  350.     public function setCollectDate(?\DateTimeInterface $collectDate): self
  351.     {
  352.         $this->collectDate $collectDate;
  353.         return $this;
  354.     }
  355.     public function getCollectTime(): ?\DateTimeInterface
  356.     {
  357.         return $this->collectTime;
  358.     }
  359.     public function setCollectTime(?\DateTimeInterface $collectTime): self
  360.     {
  361.         $this->collectTime $collectTime;
  362.         return $this;
  363.     }
  364.     public function getShippingDate(): ?\DateTimeInterface
  365.     {
  366.         return $this->shippingDate;
  367.     }
  368.     public function setShippingDate(?\DateTimeInterface $shippingDate): self
  369.     {
  370.         $this->shippingDate $shippingDate;
  371.         return $this;
  372.     }
  373.     public function getShippingTime(): ?\DateTimeInterface
  374.     {
  375.         return $this->shippingTime;
  376.     }
  377.     public function setShippingTime(?\DateTimeInterface $shippingTime): self
  378.     {
  379.         $this->shippingTime $shippingTime;
  380.         return $this;
  381.     }
  382.     /**
  383.      * @return Collection<int, ShipmentItemChild>
  384.      */
  385.     public function getShipmentItemChildren(): Collection
  386.     {
  387.         return $this->shipmentItemChildren;
  388.     }
  389.     public function addShipmentItemChild(ShipmentItemChild $shipmentItemChild): self
  390.     {
  391.         if (!$this->shipmentItemChildren->contains($shipmentItemChild)) {
  392.             $this->shipmentItemChildren->add($shipmentItemChild);
  393.             $shipmentItemChild->setShipmentItem($this);
  394.         }
  395.         return $this;
  396.     }
  397.     public function removeShipmentItemChild(ShipmentItemChild $shipmentItemChild): self
  398.     {
  399.         if ($this->shipmentItemChildren->removeElement($shipmentItemChild)) {
  400.             // set the owning side to null (unless already changed)
  401.             if ($shipmentItemChild->getShipmentItem() === $this) {
  402.                 $shipmentItemChild->setShipmentItem(null);
  403.             }
  404.         }
  405.         return $this;
  406.     }
  407.     public function getAllTrackedChildren(){
  408.         $children = [];
  409.         
  410.             foreach($this->getShipmentItemChildren() as $singleChild){
  411.                 if($singleChild->getTrackingSteps()->contains($this->getShipment()->getTrackingSteps()->last()) ){
  412.                     $children[]= $singleChild;
  413.                 }   
  414.         }
  415.         return $children;
  416.     }
  417.     public function getWeight(): ?float
  418.     {
  419.         return $this->weight;
  420.     }
  421.     public function setWeight(?float $weight): self
  422.     {
  423.         $this->weight $weight;
  424.         return $this;
  425.     }
  426.     public function getShipmentItemType(): ?ShipmentItemType
  427.     {
  428.         return $this->shipmentItemType;
  429.     }
  430.     public function setShipmentItemType(?ShipmentItemType $shipmentItemType): self
  431.     {
  432.         $this->shipmentItemType $shipmentItemType;
  433.         return $this;
  434.     }
  435. }