123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- <?php
- namespace App\Http\Requests\Client\Comment;
- use Illuminate\Foundation\Http\FormRequest;
- class CreateRequest extends FormRequest
- {
- public function authorize(): bool
- {
- return true;
- }
- public function rules(): array
- {
- return [
- 'order_id' => [
- 'required',
- 'integer',
- 'exists:order,id',
- ],
- 'score' => [
- 'required',
- 'integer',
- 'min:1',
- 'max:5',
- ],
- 'content' => [
- 'nullable',
- 'string',
- 'max:500',
- ],
- 'images' => [
- 'nullable',
- 'array',
- 'max:9',
- ],
- 'images.*' => [
- 'required',
- 'string',
- 'max:255',
- ],
- 'is_anonymous' => [
- 'nullable',
- 'boolean',
- ],
- 'tag_ids' => [
- 'nullable',
- 'array',
- 'max:5',
- ],
- 'tag_ids.*' => [
- 'required',
- 'integer',
- 'exists:coach_comment_tags,id',
- ],
- ];
- }
- public function messages(): array
- {
- return [
- 'order_id.required' => '订单ID不能为空',
- 'order_id.integer' => '订单ID必须是整数',
- 'order_id.exists' => '订单不存在',
- 'score.required' => '评分不能为空',
- 'score.integer' => '评分必须是整数',
- 'score.min' => '评分最小为1分',
- 'score.max' => '评分最大为5分',
- 'content.max' => '评价内容不能超过500个字符',
- 'images.array' => '图片必须是数组',
- 'images.max' => '最多上传9张图片',
- 'images.*.required' => '图片不能为空',
- 'images.*.string' => '图片必须是字符串',
- 'images.*.max' => '图片地址不能超过255个字符',
- 'is_anonymous.boolean' => '是否匿名必须是布尔值',
- 'tag_ids.array' => '标签必须是数组',
- 'tag_ids.max' => '最多选择5个标签',
- 'tag_ids.*.required' => '标签ID不能为空',
- 'tag_ids.*.integer' => '标签ID必须是整数',
- 'tag_ids.*.exists' => '标签不存在',
- ];
- }
- }
|