123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- <?php
- namespace App\Http\Requests\Coach;
- use Illuminate\Foundation\Http\FormRequest;
- class SubmitBaseInfoRequest extends FormRequest
- {
- public function authorize()
- {
- return true;
- }
- public function rules()
- {
- return [
- 'nickname' => 'nullable|string|min:2|max:20',
- 'avatar' => 'nullable|string|max:2048',
- 'life_photos' => 'nullable|array',
- 'life_photos.*' => 'required|string|max:2048',
- 'gender' => 'required|string|in:1,2',
- 'mobile' => 'required|string|size:11',
- 'birthday' => 'nullable|date|before:' . now()->subYears(18)->format('Y-m-d'),
- 'work_years' => 'nullable|integer|min:0|max:99',
- 'intention_city' => 'nullable|string|max:50',
- 'introduction' => 'nullable|string|min:10|max:255',
- ];
- }
- public function messages()
- {
- return [
- 'nickname.string' => '昵称必须是字符串',
- 'nickname.min' => '昵称不能少于2个字符',
- 'nickname.max' => '昵称不能超过20个字符',
- 'avatar.string' => '头像必须是有效的字符串',
- 'avatar.max' => '头像大小不能超过2048字节',
- 'gender.required' => '性别不能为空',
- 'gender.in' => '性别只能是1(男)或2(女)',
- 'mobile.required' => '手机号不能为空',
- 'mobile.string' => '手机号必须是有效的字符串',
- 'mobile.size' => '手机号长度必须是11位',
- 'birthday.date' => '出生日期格式不正确',
- 'birthday.before' => '年龄必须满18岁',
- 'work_years.integer' => '工作年限必须是整数',
- 'work_years.min' => '工作年限不能小于0年',
- 'work_years.max' => '工作年限不能超过99年',
- 'intention_city.max' => '意向城市不能超过50个字符',
- 'introduction.min' => '个人简介不能少于10个字符',
- 'introduction.max' => '个人简介不能超过255个字符',
- 'life_photos.array' => '生活照片必须是数组格式',
- 'life_photos.*.required' => '生活照片不能为空',
- 'life_photos.*.string' => '生活照片格式不正确',
- 'life_photos.*.max' => '生活照片数据过大',
- ];
- }
- }
|