RegisterRequest.php 2.2 KB
<?php
/**
 +-----------------------------------------------------------------------------------------------------------------------
 * 数据验证层:
 +-----------------------------------------------------------------------------------------------------------------------
 *
 * @copyright   Copyright
 * @author      Richer
 * @package     App\Http\Requests
 * @version     20190312
 * @link
 */
namespace App\Http\Requests;

class RegisterRequest extends BaseRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get custom attributes for validator errors.
     *
     * @return array
     */
    public function attributes()
    {
        return [
//            'openid'        => 'openid',
            'code'          => '验证码',
            'mobile'        => '手机号码',
            'password'      => '密码',
            'password_confirmation' => '确认密码'
        ];
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
//            'mobile'        =>'required|unique:users,mobile|regex:/^1[123456789][0-9]{9}$/',
            'code'          =>'required',
            'mobile'        =>'required|regex:/^1[123456789][0-9]{9}$/',
            'password'      =>'required|min:6',
            'password_confirmation'     =>'required|min:6|same:password',
        ];
    }

    public function messages()
    {
        return [
//            'mobile.required'                   => '请填写您的手机号码',
//            'mobile.regex'                      => '您的手机号码格式不正确',
//            'mobile.unique'                     => '该手机号码已经注册过了',
//            'password.required'                 => '请填写您的密码',
//            'password.min'                      => '密码最短为6位',
//            'password_confirmation.required'    => '请再次输入您的密码',
//            'password_confirmation.min'         => '密码最短为6位',
//            'password_confirmation.same'        => '两次密码不相同',
        ];
    }
}