CreateRoleRequest::rules()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 8
Ratio 100 %

Importance

Changes 0
Metric Value
dl 8
loc 8
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 0
1
<?php
2
3
namespace App\Containers\Authorization\UI\API\Requests;
4
5
use App\Ship\Parents\Requests\Request;
6
use Validator;
7
8
/**
9
 * Class CreateRoleRequest.
10
 *
11
 * @author Mahmoud Zalt <[email protected]>
12
 */
13 View Code Duplication
class CreateRoleRequest extends Request
0 ignored issues
show
Duplication introduced by
This class 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...
14
{
15
16
    /**
17
     * Define which Roles and/or Permissions has access to this request.
18
     *
19
     * @var  array
20
     */
21
    protected $access = [
22
        'roles'       => 'admin',
23
        'permissions' => '',
24
    ];
25
26
    /**
27
     * Id's that needs decoding before applying the validation rules.
28
     *
29
     * @var  array
30
     */
31
    protected $decode = [
32
33
    ];
34
35
    /**
36
     * Defining the URL parameters (`/stores/999/items`) allows applying
37
     * validation rules on them and allows accessing them like request data.
38
     *
39
     * @var  array
40
     */
41
    protected $urlParameters = [
42
43
    ];
44
45
    /**
46
     * @return  array
47
     */
48
    public function rules()
49
    {
50
        return [
51
            'name'         => 'required|unique:roles,name|min:2|max:20|no_spaces',
52
            'description'  => 'max:255',
53
            'display_name' => 'max:100',
54
        ];
55
    }
56
57
    /**
58
     * @return  bool
59
     */
60
    public function authorize()
61
    {
62
        return $this->check([
63
            'hasAccess',
64
        ]);
65
    }
66
}
67