*/ public function rules(): array { return [ 'buyable_type' => ['required', 'string', Rule::in(['variant', 'bundle'])], 'buyable_id' => ['required', 'integer'], 'cantidad' => ['required', 'integer', 'min:1'], ]; } public function mappedBuyableType(): string { return match ($this->input('buyable_type')) { 'variant' => ProductVariant::class, 'bundle' => Bundle::class, default => throw new \InvalidArgumentException('Invalid buyable type'), }; } }