feat(variants): add filtering for inactive event dates in visibleVariants method
This commit is contained in:
@@ -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> */
|
||||
|
||||
Reference in New Issue
Block a user