feat(catalog): replace selectionOptions with selectorOptions to filter hidden attributes
This commit is contained in:
@@ -268,6 +268,25 @@ class Variant extends Model
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Collection<int, ItemAttribute> $itemAttributes
|
||||
* @return Collection<string, array{value: string, label: string}|array<int, array{value: string, label: string}>>
|
||||
*/
|
||||
public function selectorOptions(Collection $itemAttributes): Collection
|
||||
{
|
||||
$visibleAttributeCodes = $itemAttributes
|
||||
->filter(fn (ItemAttribute $itemAttribute): bool => $itemAttribute->show_in_selector)
|
||||
->map(fn (ItemAttribute $itemAttribute): ?string => $itemAttribute->attribute?->codigo)
|
||||
->filter()
|
||||
->values();
|
||||
|
||||
return $this->selectionOptions($itemAttributes)
|
||||
->filter(
|
||||
fn (array $option, string $attributeCode): bool => $visibleAttributeCodes
|
||||
->contains($attributeCode)
|
||||
);
|
||||
}
|
||||
|
||||
/** @return Collection<int, EventDate> */
|
||||
public function selectedEventDates(): Collection
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user