feat(variants): add filtering for inactive event dates in visibleVariants method

This commit is contained in:
2026-09-14 16:52:34 -03:00
parent c27d9628fd
commit 9fa4da7de2
3 changed files with 50 additions and 6 deletions

View File

@@ -95,7 +95,22 @@ class Variant extends Model
public function isSellable(): bool
{
return $this->sales_disabled_at === null
&& $this->replaced_by_variant_id === null;
&& $this->replaced_by_variant_id === null
&& $this->hasOnlyActiveEventDates();
}
public function hasOnlyActiveEventDates(): bool
{
if (! $this->exists
&& $this->event_date_id === null
&& ! $this->relationLoaded('eventDates')) {
return true;
}
return $this->selectedEventDates()->every(
fn (EventDate $eventDate): bool => $eventDate->rescheduled_to_event_date_id === null
&& $eventDate->suspended_at === null,
);
}
/** @return HasMany<VariantDefinition, $this> */