feat: enhance item attributes management by adding sort order; update related models, resources, and tests for visibility and ordering of variants
This commit is contained in:
@@ -21,6 +21,12 @@ class FoodService
|
||||
{
|
||||
private const ATTRIBUTE_CODES = ['event_date', 'horario', 'servicio'];
|
||||
|
||||
private const ATTRIBUTE_SORT_ORDERS = [
|
||||
'event_date' => 1,
|
||||
'horario' => 2,
|
||||
'servicio' => 3,
|
||||
];
|
||||
|
||||
public function __construct(private readonly CatalogService $catalogService) {}
|
||||
|
||||
public function current(Tenant $tenant): ?CatalogItem
|
||||
@@ -169,9 +175,12 @@ class FoodService
|
||||
private function itemAttributes(CatalogItem $food, Collection $attributes): Collection
|
||||
{
|
||||
return $attributes->mapWithKeys(function (Attribute $attribute, string $code) use ($food): array {
|
||||
$itemAttribute = $food->itemAttributes()->firstOrCreate(
|
||||
$itemAttribute = $food->itemAttributes()->updateOrCreate(
|
||||
['attribute_id' => $attribute->id],
|
||||
['allow_multi_select' => false],
|
||||
[
|
||||
'allow_multi_select' => false,
|
||||
'sort_order' => self::ATTRIBUTE_SORT_ORDERS[$code],
|
||||
],
|
||||
);
|
||||
|
||||
return [$code => $itemAttribute];
|
||||
|
||||
Reference in New Issue
Block a user