Completed
Push — master ( 5e765d...c5065d )
by wen
03:03
created

StoreRequest::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
use Sco\Admin\Contracts\Config as ConfigContract;
7
8
class StoreRequest extends BaseFormRequest
9
{
10
    protected $configFactory;
11
12
    public function __construct(ConfigContract $config)
13
    {
14
        parent::__construct();
15
16
        $this->configFactory = $config;
17
    }
18
19
    /**
20
     * Determine if the user is authorized to make this request.
21
     *
22
     * @return bool
23
     */
24
    public function authorize()
25
    {
26
        return true;
27
    }
28
29
    /**
30
     * Get the validation rules that apply to the request.
31
     *
32
     * @return array
33
     */
34
    public function rules()
35
    {
36
        return $this->configFactory->getRules();
37
    }
38
39
    protected function getMessages()
40
    {
41
        return [
42
            'regex'   => '字母数字',
43
            'between' => trans('admin::validation.between.string'),
44
            'min'     => trans('admin::validation.min.string'),
45
        ];
46
    }
47
48
    protected function getAttributes()
49
    {
50
        return [
51
            'name' => '管理员名称',
52
        ];
53
    }
54
}
55