Skip to content

Commit

Permalink
fix: reset index after filtering packages
Browse files Browse the repository at this point in the history
  • Loading branch information
Atala committed Feb 6, 2025
1 parent b906053 commit 126ae09
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
5 changes: 4 additions & 1 deletion src/Entity/PackageSet.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()));
}

/**
Expand Down
12 changes: 6 additions & 6 deletions src/Entity/Store.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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();
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -672,5 +673,4 @@ public function getStoreGLN(): ?string
{
return $this->storeGLN;
}

}

0 comments on commit 126ae09

Please sign in to comment.