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

UpdateRoleRequest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 55
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 3
dl 0
loc 55
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A authorize() 0 4 1
A rules() 0 22 1
A getMessages() 0 7 1
A getAttributes() 0 6 1
1
<?php
2
3
namespace Sco\Admin\Http\Requests;
4
5
use Illuminate\Validation\Rule;
6
7
class UpdateRoleRequest 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
    public function rules()
25
    {
26
        return [
27
            'id'           => 'integer',
28
            'name'         => [
29
                'bail',
30
                'required',
31
                'regex:/^[a-z0-9]+$/i',
32
                'max: 50',
33
                Rule::unique(config('admin.roles_table'))->ignore($this->input('id')),
34
            ],
35
            'display_name' => [
36
                'bail',
37
                'required',
38
                'alpha_num',
39
            ],
40
            'description' => [
41
                'bail',
42
                'alpha_num',
43
            ],
44
        ];
45
    }
46
47
    protected function getMessages()
48
    {
49
        return [
50
            'max'   => trans('admin::validation.max.string'),
51
            'regex' => '字母数字',
52
        ];
53
    }
54
55
    protected function getAttributes()
56
    {
57
        return [
58
            'name' => '标识',
59
        ];
60
    }
61
}
62