123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- <?php
- namespace App\Http\Requests\Client\User;
- use Illuminate\Foundation\Http\FormRequest;
- class ApplyCoachRequest extends FormRequest
- {
- public function authorize(): bool
- {
- return true;
- }
- public function rules(): array
- {
- return [
- 'age' => [
- 'required',
- 'integer',
- 'between:18,60',
- ],
- 'mobile' => [
- 'required',
- 'string',
- 'size:11',
- 'regex:/^1[3-9]\d{9}$/',
- ],
- 'gender' => [
- 'required',
- 'integer',
- 'in:1,2',
- ],
- 'work_years' => [
- 'required',
- 'integer',
- 'min:0',
- 'max:50',
- ],
- 'intention_city' => [
- 'required',
- 'string',
- 'max:50',
- ],
- 'life_photos' => [
- 'required',
- 'array',
- 'min:1',
- 'max:6',
- ],
- 'life_photos.*' => [
- 'required',
- 'string',
- 'max:2048', // 限制单张图片大小
- ],
- 'introduction' => [
- 'nullable',
- 'string',
- 'max:1000',
- ],
- ];
- }
- public function messages(): array
- {
- return [
- 'age.required' => '年龄不能为空',
- 'age.integer' => '年龄必须是整数',
- 'age.between' => '年龄必须在18-60岁之间',
- 'mobile.required' => '手机号不能为空',
- 'mobile.size' => '手机号必须是11位',
- 'mobile.regex' => '手机号格式不正确',
- 'gender.required' => '性别不能为空',
- 'gender.in' => '性别只能是1(男)或2(女)',
- 'work_years.required' => '工作年限不能为空',
- 'work_years.integer' => '工作年限必须是整数',
- 'work_years.min' => '工作年限不能小于0年',
- 'work_years.max' => '工作年限不能超过50年',
- 'intention_city.required' => '意向城市不能为空',
- 'intention_city.max' => '意向城市不能超过50个字符',
- 'life_photos.required' => '生活照片不能为空',
- 'life_photos.array' => '生活照片必须是数组',
- 'life_photos.min' => '至少上传1张生活照片',
- 'life_photos.max' => '最多上传6张生活照片',
- 'life_photos.*.required' => '生活照片不能为空',
- 'life_photos.*.string' => '生活照片格式不正确',
- 'life_photos.*.max' => '单张照片大小不能超过2MB',
- 'introduction.max' => '个人简介不能超过1000字',
- ];
- }
- }
|