erp-backend/app/Http/Requests/PurchaseOrderReviewRequest.php
2026-04-01 17:07:04 +08:00

44 lines
1019 B
PHP

<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class PurchaseOrderReviewRequest 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
{
$rules = [];
if ($this->is('api/purchase-orders/*/reject')) {
$rules['comment'] = 'required|string|max:500';
} elseif ($this->is('api/purchase-orders/*/approve')) {
$rules['comment'] = 'nullable|string|max:500';
}
return $rules;
}
/**
* Get custom messages for validator errors.
*/
public function messages(): array
{
return [
'comment.required' => '驳回原因不能为空',
];
}
}