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

42 lines
1.3 KiB
PHP

<?php namespace App\Http\Requests\App;
use Illuminate\Foundation\Http\FormRequest;
class PriceUpdateRequest 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.
*
*/
public function rules(): array
{
return [
'cost' => ['nullable', 'numeric', 'min:0'],
'retail_price' => ['nullable', 'numeric', 'min:0', 'gt:cost'],
'tax' => ['nullable', 'numeric', 'min:0', 'max:100'],
];
}
public function messages(): array
{
return [
'cost.numeric' => 'El costo debe ser un número.',
'cost.min' => 'El costo no puede ser negativo.',
'retail_price.numeric' => 'El precio de venta debe ser un número.',
'retail_price.min' => 'El precio de venta no puede ser negativo.',
'retail_price.gt' => 'El precio de venta debe ser mayor que el costo.',
'tax.numeric' => 'El impuesto debe ser un número.',
'tax.min' => 'El impuesto no puede ser negativo.',
'tax.max' => 'El impuesto no puede exceder el 100%.',
];
}
}