diff --git a/app/Http/Requests/UserRequest.php b/app/Http/Requests/UserRequest.php index 9122f1ad5..4814b5842 100644 --- a/app/Http/Requests/UserRequest.php +++ b/app/Http/Requests/UserRequest.php @@ -18,12 +18,15 @@ public function rules() 'name' => 'required|between:3,25|regex:/^[A-Za-z0-9\-\_]+$/|unique:users,name,' . Auth::id(), 'email' => 'required|email', 'introduction' => 'max:80', + 'avatar' => 'mimes:jpeg,bmp,png,gif|dimensions:min_width=208,min_height=208', ]; } public function messages() { return [ + 'avatar.mimes' =>'头像必须是 jpeg, bmp, png, gif 格式的图片', + 'avatar.dimensions' => '图片的清晰度不够,宽和高需要 208px 以上', 'name.unique' => '用户名已被占用,请重新填写', 'name.regex' => '用户名只支持英文、数字、横杠和下划线。', 'name.between' => '用户名必须介于 3 - 25 个字符之间。',