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

53 lines
1.6 KiB
PHP

<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class TemplateRequest 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 [
'name' => 'required|string|max:100',
'platform' => 'required|in:common,jd,pdd,taobao',
'size' => 'required|string|max:50',
'style' => 'required|string',
'default_express' => 'nullable|string|max:50',
'sender_name' => 'required|string|max:50',
'sender_phone' => 'required|string|max:20',
'sender_address' => 'required|string|max:200',
'show_product' => 'nullable|boolean',
'remark' => 'nullable|string|max:500',
];
}
/**
* Get custom messages for validator errors.
*/
public function messages(): array
{
return [
'name.required' => '模板名称不能为空',
'platform.required' => '请选择平台',
'size.required' => '请填写模板尺寸',
'style.required' => '请填写模板样式',
'sender_name.required' => '发件人姓名不能为空',
'sender_phone.required' => '发件人电话不能为空',
'sender_address.required' => '发件人地址不能为空',
];
}
}