RegisterRequest.php
2.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<?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' => '两次密码不相同',
];
}
}