pdv.backend/app/Http/Requests/App/InventoryMovementUpdateRequest.php

51 lines
2.2 KiB
PHP

<?php
namespace App\Http\Requests\App;
use Illuminate\Foundation\Http\FormRequest;
class InventoryMovementUpdateRequest extends FormRequest
{
public function authorize(): bool
{
return true;
}
public function rules(): array
{
return [
'quantity' => 'sometimes|integer|min:1',
'unit_cost' => 'sometimes|numeric|min:0',
'warehouse_from_id' => 'sometimes|nullable|exists:warehouses,id',
'warehouse_to_id' => 'sometimes|nullable|exists:warehouses,id',
'invoice_reference' => 'sometimes|nullable|string|max:255',
'notes' => 'sometimes|nullable|string|max:500',
'serial_numbers' => ['nullable', 'array'],
'serial_numbers.*' => ['string', 'max:255'],
'supplier_id' => 'sometimes|nullable|exists:suppliers,id',
'unit_of_measure_id' => 'sometimes|nullable|exists:units_of_measurement,id',
];
}
public function messages(): array
{
return [
'quantity.required' => 'La cantidad es requerida',
'quantity.integer' => 'La cantidad debe ser un número entero',
'quantity.min' => 'La cantidad debe ser al menos 1',
'unit_cost.required' => 'El costo unitario es requerido',
'unit_cost.numeric' => 'El costo unitario debe ser un número',
'unit_cost.min' => 'El costo unitario no puede ser negativo',
'warehouse_from_id.required' => 'El almacén origen es requerido',
'warehouse_from_id.exists' => 'El almacén origen no existe',
'warehouse_from_id.different' => 'El almacén origen debe ser diferente al destino',
'warehouse_to_id.required' => 'El almacén destino es requerido',
'warehouse_to_id.exists' => 'El almacén destino no existe',
'warehouse_to_id.different' => 'El almacén destino debe ser diferente al origen',
'notes.max' => 'Las notas no pueden exceder 1000 caracteres',
'invoice_reference.max' => 'La referencia de factura no puede exceder 255 caracteres',
'serial_numbers.array' => 'Los números de serie deben ser un arreglo',
];
}
}