36 lines
994 B
PHP
36 lines
994 B
PHP
<?php
|
|
|
|
namespace App\Http\Requests\Admin\Manage\Purchase;
|
|
|
|
use Illuminate\Contracts\Validation\ValidationRule;
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
use Illuminate\Validation\Rule;
|
|
|
|
class PurchaseRequest extends FormRequest
|
|
{
|
|
/**
|
|
* Determine if the user is authorized to make this request.
|
|
*/
|
|
public function authorize(): bool
|
|
{
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
* Get the validation rules that apply to the request.
|
|
*
|
|
* @return array<string, ValidationRule|array<mixed>|string>
|
|
*/
|
|
public function rules(): array
|
|
{
|
|
return [
|
|
'purchase_date' => ['required', 'date'],
|
|
'note' => ['nullable', 'string', 'max:100'],
|
|
'items' => ['required', 'array', 'min:1'],
|
|
'items.*.product_id' => ['required', Rule::exists('products', 'id')],
|
|
'items.*.quantity' => ['required', 'integer', 'min:1'],
|
|
'items.*.unit_price' => ['required', 'integer', 'min:0'],
|
|
];
|
|
}
|
|
}
|