getMethod()) { case "PUT": return [ 'sex' => 'in:1,2', 'feed_sex' => 'in:1,2', 'nickname' => 'between:1,12', 'height' => 'integer|between:150,200', 'introduce' => 'max:180', 'expect' => 'max:180', 'qq' => ['integer', 'regex:/^[0-9_]{5,10}$/'], 'weixin' => ['regex:/^[a-zA-Z]{1}[-_a-zA-Z0-9]{5,19}$/'], 'school' => 'string', 'age' => ["before_or_equal:-18year", "after_or_equal:-100year"] ]; break; default: return []; } } public function messages() { return [ 'sex.*' => '性别只能选取[男/女]', 'feed_sex.*' => '性取向只能选取[男/女]', 'weixin.*' => '请输入正确的微信号', 'qq.*' => '请输入正确的QQ号', 'school.*' => '请输入正确的学校全称', 'age.before_or_equal' => '生日 必须18周岁以上', 'age.after_or_equal' => '生日 必须100周岁以下', ]; } public function attributes() { return [ 'sex' => '性别', 'feed_sex' => '性取向', 'nickname' => '昵称', 'introduce' => '个性签名', 'expect' => '期望', 'height' => '身高', 'age' => '生日', 'weixin' => '微信号', 'qq' => 'QQ号', ]; } }