diff --git a/src/Entity/PackageSet.php b/src/Entity/PackageSet.php index e78b3eeb7d..e76f9173d9 100644 --- a/src/Entity/PackageSet.php +++ b/src/Entity/PackageSet.php @@ -88,11 +88,14 @@ public function setName($name) */ public function getPackages() { - return $this->packages->filter( + $filtered = $this->packages->filter( function ($package) { return !$package->isDeleted(); } ); + + // reset index after filtering + return new ArrayCollection(array_values($filtered->toArray())); } /** diff --git a/src/Entity/Store.php b/src/Entity/Store.php index 12d4cc0a0b..5be1fcd1d9 100644 --- a/src/Entity/Store.php +++ b/src/Entity/Store.php @@ -208,7 +208,7 @@ class Store extends LocalBusiness implements TaggableInterface, OrganizationAwar /** * The deliveries of this store will be linked by default to this rider * @var User - */ + */ private $defaultCourier; protected string $billingMethod = 'unit'; @@ -219,7 +219,8 @@ class Store extends LocalBusiness implements TaggableInterface, OrganizationAwar */ protected ?string $storeGLN = null; - public function __construct() { + public function __construct() + { $this->deliveries = new ArrayCollection(); $this->owners = new ArrayCollection(); $this->addresses = new ArrayCollection(); @@ -552,7 +553,7 @@ public function setMultiDropEnabled($multiDropEnabled) public function getTimeSlots() { - return $this->timeSlots->map(fn (StoreTimeSlot $sts): TimeSlot => $sts->getTimeSlot()); + return $this->timeSlots->map(fn(StoreTimeSlot $sts): TimeSlot => $sts->getTimeSlot()); } public function setTimeSlots($timeSlots): void @@ -611,13 +612,13 @@ public function setTimeSlots($timeSlots): void public function getPackages() { if (null !== $this->packageSet) { - return array_values($this->packageSet->getPackages()->toArray()); + return $this->packageSet->getPackages(); } return []; } - public function isTransporterEnabled(): bool + public function isTransporterEnabled(): bool { return !is_null($this->transporter); } @@ -672,5 +673,4 @@ public function getStoreGLN(): ?string { return $this->storeGLN; } - }