24 lines
629 B
PHP
24 lines
629 B
PHP
<?php
|
|
|
|
namespace App\Http\Requests\Api\V1\Cart;
|
|
|
|
use App\Rules\ProductStockIsAvailable;
|
|
use Illuminate\Contracts\Validation\ValidationRule;
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
|
|
class CartStoreRequest extends FormRequest
|
|
{
|
|
/**
|
|
* Get the validation rules that apply to the request.
|
|
*
|
|
* @return array<string, ValidationRule|array<mixed>|string>
|
|
*/
|
|
public function rules(): array
|
|
{
|
|
return [
|
|
'product_id' => ['required', 'integer', new ProductStockIsAvailable($this->product_quantity)],
|
|
'product_quantity' => ['required', 'integer', 'min:1'],
|
|
];
|
|
}
|
|
}
|