feat: refactor cart item handling to use mapped buyable types and improve method signatures
This commit is contained in:
@@ -22,4 +22,13 @@ class AddCartItemRequest extends FormRequest
|
||||
'cantidad' => ['required', 'integer', 'min:1'],
|
||||
];
|
||||
}
|
||||
|
||||
public function mappedBuyableType(): string
|
||||
{
|
||||
return match ($this->input('buyable_type')) {
|
||||
'variant' => \App\Domains\Catalog\Models\ProductVariant::class,
|
||||
'bundle' => \App\Domains\Bundle\Models\Bundle::class,
|
||||
default => throw new \InvalidArgumentException('Invalid buyable type'),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user