codigo === 'fiesta_futbol_infantil') { Attribute::query() ->where('tenant_codigo', $tenant->codigo) ->whereIn('codigo', ['color', 'talle', 'talle_numerico']) ->delete(); } if ($tenant->codigo !== 'fiesta_futbol_infantil') { $this->seedAttribute($tenant, [ 'codigo' => 'color', 'nombre' => 'Color', 'type' => FieldType::Select->value, 'is_required' => true, 'metadata_schema' => [ 'hex' => ['type' => 'string'], ], 'options' => [ [ 'value' => 'Negro', 'label' => 'Negro', 'sort_order' => 1, 'metadata' => ['hex' => '#000000'], ], [ 'value' => 'Gris', 'label' => 'Gris', 'sort_order' => 2, 'metadata' => ['hex' => '#808080'], ], [ 'value' => 'Blanco', 'label' => 'Blanco', 'sort_order' => 3, 'metadata' => ['hex' => '#FFFFFF'], ], [ 'value' => 'Azul', 'label' => 'Azul', 'sort_order' => 4, 'metadata' => ['hex' => '#0000FF'], ], ], ]); } // Seed Talle (Size - Text options) attribute if ($tenant->codigo !== 'fiesta_futbol_infantil') { $this->seedAttribute($tenant, [ 'codigo' => 'talle', 'nombre' => 'Talle', 'type' => FieldType::Select->value, 'is_required' => true, 'options' => [ ['value' => 'S', 'label' => 'S', 'sort_order' => 1], ['value' => 'M', 'label' => 'M', 'sort_order' => 2], ['value' => 'L', 'label' => 'L', 'sort_order' => 3], ['value' => 'XL', 'label' => 'XL', 'sort_order' => 4], ], ]); } // Seed Talle Numérico (Numeric Size options) attribute if ($tenant->codigo !== 'fiesta_futbol_infantil') { $this->seedAttribute($tenant, [ 'codigo' => 'talle_numerico', 'nombre' => 'Talle Numérico', 'type' => FieldType::Select->value, 'is_required' => true, 'options' => [ ['value' => '38', 'label' => '38', 'sort_order' => 1], ['value' => '40', 'label' => '40', 'sort_order' => 2], ['value' => '42', 'label' => '42', 'sort_order' => 3], ['value' => '44', 'label' => '44', 'sort_order' => 4], ], ]); } // Seed Fecha attribute $this->seedAttribute($tenant, [ 'codigo' => 'fecha', 'nombre' => 'Fecha', 'type' => FieldType::Select->value, 'is_required' => true, 'options' => [ ['value' => '2026-10-09', 'label' => '09/10/2026', 'sort_order' => 1], ['value' => '2026-10-10', 'label' => '10/10/2026', 'sort_order' => 2], ['value' => '2026-10-11', 'label' => '11/10/2026', 'sort_order' => 3], ['value' => '2026-10-12', 'label' => '12/10/2026', 'sort_order' => 4], ], ]); } } /** * @param array $data */ private function seedAttribute(Tenant $tenant, array $data): void { $options = $data['options'] ?? []; unset($data['options']); $attribute = Attribute::query()->updateOrCreate( [ 'tenant_codigo' => $tenant->codigo, 'codigo' => $data['codigo'], ], $data, ); $attribute->options()->delete(); $attribute->options()->createMany($options); } }