/** * Gets the last updated shipment of the order * * @return false|ShipmentInterface */ public function getLastShipment() { if ($this->shipments->isEmpty()) { return false; } $last = $this->shipments->first(); foreach ($this->shipments as $shipment) { if ($shipment->getUpdatedAt() > $last->getUpdatedAt()) { $last = $shipment; } } return $last; }
/** * {@inheritdoc} */ public function hasShipment(ShipmentInterface $shipment) { return $this->shipments->contains($shipment); }
/** * @inheritdoc */ public function removeShipment(ShipmentInterface $shipment) { if ($this->hasShipment($shipment)) { $shipment->setOrder(null); $this->shipments->removeElement($shipment); } return $this; }