feat: refactor cart and purchase handling to support polymorphic buyable types and improve code readability

This commit is contained in:
2026-07-16 09:55:38 -03:00
parent c05206cc51
commit 6fc6ed1fac
14 changed files with 196 additions and 79 deletions

View File

@@ -99,7 +99,10 @@ class ProductVariant extends Model implements Buyable
if ($this->relationLoaded('definitions') && $this->definitions->isNotEmpty()) {
$definitions = $this->definitions->map(function ($def) {
return $def->value ?? $def->productAttribute?->attribute?->nombre;
$attributeName = $def->productAttribute?->attribute?->nombre;
$value = $def->value;
return $attributeName ? "{$attributeName}: {$value}" : $value;
})->filter()->implode(', ');
if ($definitions !== '') {