Completed
Push — master ( 80411a...1281a7 )
by wen
03:35
created

StoreUserRequest::authorize()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace Sco\Admin\Http\Requests;
4
5
use Illuminate\Validation\Rule;
6
7
class StoreUserRequest extends BaseFormRequest
8
{
9
    /**
10
     * Determine if the user is authorized to make this request.
11
     *
12
     * @return bool
13
     */
14
    public function authorize()
15
    {
16
        return true;
17
    }
18
19
    /**
20
     * Get the validation rules that apply to the request.
21
     *
22
     * @return array
23
     */
24 View Code Duplication
    public function rules()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
25
    {
26
        return [
27
            'name'     => [
28
                'bail',
29
                'required',
30
                'regex:/^[a-z0-9]+$/i',
31
                'between:4,20',
32
                Rule::unique(config('admin.users_table'))
33
            ],
34
            'email'    => [
35
                'bail',
36
                'email',
37
                'required',
38
                Rule::unique(config('admin.users_table')),
39
            ],
40
            'password' => 'bail|required|min:6',
41
        ];
42
    }
43
44
    protected function getMessages()
45
    {
46
        return [
47
            'regex'   => '字母数字',
48
            'between' => trans('admin::validation.between.string'),
49
            'min'     => trans('admin::validation.min.string'),
50
        ];
51
    }
52
53
    protected function getAttributes()
54
    {
55
        return [
56
            'name' => '管理员名称',
57
        ];
58
    }
59
}
60