ldc-cocotte/app/Http/Requests/Basket/RemoveBasketRequest.php
2026-10-27 09:58:12 +01:00

35 lines
728 B
PHP

<?php
declare(strict_types=1);
namespace App\Http\Requests\Basket;
use Domain\Models\ValueObjects\Entities\ProductId;
use Illuminate\Foundation\Http\FormRequest;
use Ramsey\Uuid\Uuid;
class RemoveBasketRequest extends FormRequest
{
public function authorize(): bool
{
return true;
}
/** @return array<string,mixed> */
public function rules(): array
{
return [
'rowId' => ['required', 'string', 'uuid'],
'qty' => ['sometimes', 'integer', 'gt:0'],
];
}
public function getProductId(): ProductId
{
return new ProductId(
Uuid::fromString(
$this->string('rowId')->value()
)
);
}
}