New-Thanasoft/thanasoft-back/app/Http/Requests/StoreStockItemRequest.php

49 lines
1.4 KiB
PHP

<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class StoreStockItemRequest 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, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
return [
'product_id' => 'required|exists:products,id',
'warehouse_id' => 'required|exists:warehouses,id',
'qty_on_hand_base' => 'nullable|numeric|min:0',
'safety_stock_base' => 'nullable|numeric|min:0',
];
}
/**
* Get the error messages for the defined validation rules.
*
* @return array<string, string>
*/
public function messages(): array
{
return [
'product_id.required' => 'Le produit est requis.',
'product_id.exists' => 'Le produit sélectionné est invalide.',
'warehouse_id.required' => 'L\'entrepôt est requis.',
'warehouse_id.exists' => 'L\'entrepôt sélectionné est invalide.',
'qty_on_hand_base.numeric' => 'La quantité en stock doit être un nombre.',
'safety_stock_base.numeric' => 'Le stock de sécurité doit être un nombre.',
];
}
}