UpdateUser::authorize()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 2
nc 2
nop 0
1
<?php
2
3
namespace Itstructure\LaRbac\Http\Requests;
4
5
use Illuminate\Foundation\Http\FormRequest;
6
7
/**
8
 * Class UpdateUser
9
 *
10
 * @package Itstructure\LaRbac\Http\Requests
11
 *
12
 * @author Andrey Girnik <[email protected]>
13
 */
14
class UpdateUser extends FormRequest
15
{
16
    /**
17
     * Determine if the user is authorized to make this request.
18
     *
19
     * @return bool
20
     */
21
    public function authorize()
22
    {
23
        return !empty(config('rbac.routesMainPermission')) ? $this->user()->can(config('rbac.routesMainPermission')) : true;
24
    }
25
26
    /**
27
     * Get the validation rules that apply to the request.
28
     *
29
     * @return array
30
     */
31
    public function rules()
32
    {
33
        return [
34
            'roles' => 'required|array',
35
        ];
36
    }
37
38
    /**
39
     * Get the error messages for the defined validation rules.
40
     *
41
     * @return array
42
     */
43
    public function messages()
44
    {
45
        return [
46
            'required' => __('rbac::validation.required'),
47
        ];
48
    }
49
50
    /**
51
     * Get custom attributes for validator errors.
52
     *
53
     * @return array
54
     */
55
    public function attributes()
56
    {
57
        return [
58
            'roles' => __('rbac::roles.roles')
59
        ];
60
    }
61
}
62