SyncPermissionsOnRoleRequest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 55
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 1
dl 0
loc 55
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A rules() 0 8 1
A authorize() 0 6 1
1
<?php
2
3
namespace App\Containers\Authorization\UI\API\Requests;
4
5
use App\Ship\Parents\Requests\Request;
6
7
/**
8
 * Class SyncPermissionsOnRoleRequest.
9
 *
10
 * @author Mahmoud Zalt <[email protected]>
11
 */
12
class SyncPermissionsOnRoleRequest extends Request
13
{
14
15
    /**
16
     * Define which Roles and/or Permissions has access to this request.
17
     *
18
     * @var  array
19
     */
20
    protected $access = [
21
        'roles'       => '',
22
        'permissions' => 'manage-roles',
23
    ];
24
25
    /**
26
     * Id's that needs decoding before applying the validation rules.
27
     *
28
     * @var  array
29
     */
30
    protected $decode = [
31
        'permissions_ids.*',
32
        'role_id',
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
            'permissions_ids'   => 'required',
52
            'permissions_ids.*' => 'exists:permissions,id',
53
            'role_id'           => 'required|exists:roles,id',
54
        ];
55
    }
56
57
    /**
58
     * @return  bool
59
     */
60
    public function authorize()
61
    {
62
        return $this->check([
63
            'hasAccess',
64
        ]);
65
    }
66
}
67