refactor(catalog): add event date attribute with dynamic options and update related logic
This commit is contained in:
@@ -44,14 +44,17 @@ class CatalogService
|
||||
$hasEventDateVariants = $variants !== [] && collect($variants)->every(
|
||||
fn (array $variant): bool => ! empty($variant['event_date_id'])
|
||||
);
|
||||
$hasVariants = $attributeCodes !== [] || $hasEventDateVariants;
|
||||
|
||||
if ($hasEventDateVariants && in_array('event_date', $attributeCodes, true)) {
|
||||
if ($hasEventDateVariants && ! in_array('event_date', $attributeCodes, true)) {
|
||||
throw ValidationException::withMessages([
|
||||
'attribute_codes' => ['The event_date code is reserved for event dates.'],
|
||||
'attribute_codes' => [
|
||||
'The event_date attribute is required for event date variants.',
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
$hasVariants = $attributeCodes !== [] || $hasEventDateVariants;
|
||||
|
||||
$this->validateEventProductType($data);
|
||||
$this->validateUniqueVariantCombinations($variants, $attributeCodes);
|
||||
|
||||
@@ -154,6 +157,7 @@ class CatalogService
|
||||
'brand',
|
||||
'validityTime',
|
||||
'itemAttributes.attribute.options.validityTime',
|
||||
'itemAttributes.attribute.eventDates',
|
||||
'variants' => fn ($query) => $query->orderBy('id'),
|
||||
'variants.inventory',
|
||||
'variants.attachments',
|
||||
|
||||
Reference in New Issue
Block a user