src/Flexy/ShopBundle/Entity/Shipping/ShipmentItem.php line 16
<?php
namespace App\Flexy\ShopBundle\Entity\Shipping;
use ApiPlatform\Core\Annotation\ApiResource;
use App\Flexy\ShopBundle\Entity\Order\OrderItem;
use App\Flexy\ShopBundle\Repository\Shipping\ShipmentItemRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
#[ApiResource]
#[ORM\Entity(repositoryClass: ShipmentItemRepository::class)]
class ShipmentItem implements \Stringable
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
private $id;
#[ORM\Column(type: 'datetime_immutable', nullable: true)]
private ?\DateTimeImmutable $createdAt = null;
#[ORM\Column(type: 'boolean', nullable: true)]
private ?bool $isShippable = null;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
#[Assert\NotNull]
#[Assert\NotBlank]
#[Assert\Regex(pattern: '/[a-zA-Z0-9,.]/', message: 'Address must be alphanumeric')]
private $collectAddress;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private $collectAddressIndication;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private $collectLng;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private $collectLat;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private $collectAddressPhone;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
#[Assert\NotNull]
#[Assert\NotBlank]
#[Assert\Regex(pattern: '/[a-zA-Z0-9,.]/', message: 'Address must be alphanumeric')]
private $shippingAddress;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private $shippingAddressIndication;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private $shippingLng;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private $shippingLat;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private $shippingPhone;
#[ORM\Column(type: Types::DATE_MUTABLE, nullable: true)]
private ?\DateTimeInterface $collectDate = null;
#[ORM\Column(type: Types::TIME_MUTABLE, nullable: true)]
private ?\DateTimeInterface $collectTime = null;
#[ORM\Column(type: Types::DATE_MUTABLE, nullable: true)]
private ?\DateTimeInterface $shippingDate = null;
#[ORM\Column(type: Types::TIME_MUTABLE, nullable: true)]
private ?\DateTimeInterface $shippingTime = null;
#[ORM\ManyToOne(targetEntity: CityRegion::class, inversedBy: 'shipmentItemsShipped')]
#[ORM\JoinColumn(nullable: true)]
private $shippingCityRegion;
#[ORM\ManyToOne(targetEntity: CityRegion::class, inversedBy: 'shipmentItemsCollected')]
#[ORM\JoinColumn(nullable: true)]
private $collectCityRegion;
#[ORM\ManyToOne(targetEntity: Shipment::class, inversedBy: 'shipmentItems',cascade:["persist"])]
private ?\App\Flexy\ShopBundle\Entity\Shipping\Shipment $shipment = null;
#[ORM\OneToOne(targetEntity: OrderItem::class, mappedBy: 'shipmentItem', cascade: ['persist'])]
private $orderItem;
#[ORM\Column(nullable: true)]
private ?int $quantity = null;
#[ORM\OneToMany(mappedBy: 'shipmentItem', targetEntity: ShipmentItemChild::class)]
private Collection $shipmentItemChildren;
#[ORM\Column(nullable: true)]
private ?float $weight = null;
#[ORM\ManyToOne(inversedBy: 'shipmentItems')]
private ?ShipmentItemType $shipmentItemType = null;
public function __construct()
{
$this->shipmentItemChildren = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function __toString(): string
{
return (string)"Shipment : ".$this->getId();
}
public function getCreatedAt(): ?\DateTimeImmutable
{
return $this->createdAt;
}
public function setCreatedAt(?\DateTimeImmutable $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
public function getIsShippable(): ?bool
{
return $this->isShippable;
}
public function setIsShippable(?bool $isShippable): self
{
$this->isShippable = $isShippable;
return $this;
}
public function getShipment(): ?Shipment
{
return $this->shipment;
}
public function setShipment(?Shipment $shipment): self
{
$this->shipment = $shipment;
return $this;
}
/**
* Get the value of orderItem
*/
public function getOrderItem()
{
return $this->orderItem;
}
/**
* Set the value of orderItem
*
* @return self
*/
public function setOrderItem($orderItem)
{
$this->orderItem = $orderItem;
return $this;
}
/**
* Get the value of collectCityRegion
*/
public function getCollectCityRegion()
{
return $this->collectCityRegion;
}
/**
* Set the value of collectCityRegion
*
* @return self
*/
public function setCollectCityRegion($collectCityRegion)
{
$this->collectCityRegion = $collectCityRegion;
return $this;
}
/**
* Get the value of shippingCityRegion
*/
public function getShippingCityRegion()
{
return $this->shippingCityRegion;
}
/**
* Set the value of shippingCityRegion
*
* @return self
*/
public function setShippingCityRegion($shippingCityRegion)
{
$this->shippingCityRegion = $shippingCityRegion;
return $this;
}
/**
* Get the value of collectAddressPhone
*/
public function getCollectAddressPhone()
{
return $this->collectAddressPhone;
}
/**
* Set the value of collectAddressPhone
*
* @return self
*/
public function setCollectAddressPhone($collectAddressPhone)
{
$this->collectAddressPhone = $collectAddressPhone;
return $this;
}
/**
* Get the value of collectAddressIndication
*/
public function getCollectAddressIndication()
{
return $this->collectAddressIndication;
}
/**
* Set the value of collectAddressIndication
*
* @return self
*/
public function setCollectAddressIndication($collectAddressIndication)
{
$this->collectAddressIndication = $collectAddressIndication;
return $this;
}
/**
* Get the value of collectAddress
*/
public function getCollectAddress()
{
return $this->collectAddress;
}
/**
* Set the value of collectAddress
*
* @return self
*/
public function setCollectAddress($collectAddress)
{
$this->collectAddress = $collectAddress;
return $this;
}
/**
* Get the value of shippingPhone
*/
public function getShippingPhone()
{
return $this->shippingPhone;
}
/**
* Set the value of shippingPhone
*
* @return self
*/
public function setShippingPhone($shippingPhone)
{
$this->shippingPhone = $shippingPhone;
return $this;
}
/**
* Get the value of shippingAdressIndication
*/
public function getShippingAddressIndication()
{
return $this->shippingAddressIndication;
}
/**
* Set the value of shippingAdressIndication
*
* @return self
*/
public function setShippingAddressIndication($shippingAdressIndication)
{
$this->shippingAddressIndication = $shippingAdressIndication;
return $this;
}
/**
* Get the value of shippingAdress
*/
public function getShippingAddress()
{
return $this->shippingAddress;
}
/**
* Set the value of shippingAdress
*
* @return self
*/
public function setShippingAddress($shippingAdress)
{
$this->shippingAddress = $shippingAdress;
return $this;
}
/**
* Get the value of shippingLng
*/
public function getShippingLng()
{
return $this->shippingLng;
}
/**
* Set the value of shippingLng
*
* @return self
*/
public function setShippingLng($shippingLng)
{
$this->shippingLng = $shippingLng;
return $this;
}
/**
* Get the value of collectLng
*/
public function getCollectLng()
{
return $this->collectLng;
}
/**
* Set the value of collectLng
*
* @return self
*/
public function setCollectLng($collectLng)
{
$this->collectLng = $collectLng;
return $this;
}
/**
* Get the value of collectLat
*/
public function getCollectLat()
{
return $this->collectLat;
}
/**
* Set the value of collectLat
*
* @return self
*/
public function setCollectLat($collectLat)
{
$this->collectLat = $collectLat;
return $this;
}
/**
* Get the value of shippingLat
*/
public function getShippingLat()
{
return $this->shippingLat;
}
/**
* Set the value of shippingLat
*
* @return self
*/
public function setShippingLat($shippingLat)
{
$this->shippingLat = $shippingLat;
return $this;
}
public function getQuantity(): ?int
{
return $this->quantity;
}
public function setQuantity(?int $quantity): self
{
$this->quantity = $quantity;
return $this;
}
public function getCollectDate(): ?\DateTimeInterface
{
return $this->collectDate;
}
public function setCollectDate(?\DateTimeInterface $collectDate): self
{
$this->collectDate = $collectDate;
return $this;
}
public function getCollectTime(): ?\DateTimeInterface
{
return $this->collectTime;
}
public function setCollectTime(?\DateTimeInterface $collectTime): self
{
$this->collectTime = $collectTime;
return $this;
}
public function getShippingDate(): ?\DateTimeInterface
{
return $this->shippingDate;
}
public function setShippingDate(?\DateTimeInterface $shippingDate): self
{
$this->shippingDate = $shippingDate;
return $this;
}
public function getShippingTime(): ?\DateTimeInterface
{
return $this->shippingTime;
}
public function setShippingTime(?\DateTimeInterface $shippingTime): self
{
$this->shippingTime = $shippingTime;
return $this;
}
/**
* @return Collection<int, ShipmentItemChild>
*/
public function getShipmentItemChildren(): Collection
{
return $this->shipmentItemChildren;
}
public function addShipmentItemChild(ShipmentItemChild $shipmentItemChild): self
{
if (!$this->shipmentItemChildren->contains($shipmentItemChild)) {
$this->shipmentItemChildren->add($shipmentItemChild);
$shipmentItemChild->setShipmentItem($this);
}
return $this;
}
public function removeShipmentItemChild(ShipmentItemChild $shipmentItemChild): self
{
if ($this->shipmentItemChildren->removeElement($shipmentItemChild)) {
// set the owning side to null (unless already changed)
if ($shipmentItemChild->getShipmentItem() === $this) {
$shipmentItemChild->setShipmentItem(null);
}
}
return $this;
}
public function getAllTrackedChildren(){
$children = [];
foreach($this->getShipmentItemChildren() as $singleChild){
if($singleChild->getTrackingSteps()->contains($this->getShipment()->getTrackingSteps()->last()) ){
$children[]= $singleChild;
}
}
return $children;
}
public function getWeight(): ?float
{
return $this->weight;
}
public function setWeight(?float $weight): self
{
$this->weight = $weight;
return $this;
}
public function getShipmentItemType(): ?ShipmentItemType
{
return $this->shipmentItemType;
}
public function setShipmentItemType(?ShipmentItemType $shipmentItemType): self
{
$this->shipmentItemType = $shipmentItemType;
return $this;
}
}