35 lines
728 B
PHP
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()
|
|
)
|
|
);
|
|
}
|
|
}
|