Completed
Push — master ( 014612...36ad26 )
by Mahmoud
03:39
created

SyncPermissionOnRoleRequest::rules()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 8
rs 9.4285
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
7
/**
8
 * Class SyncPermissionOnRoleRequest.
9
 *
10
 * @author Mahmoud Zalt <[email protected]>
11
 */
12
class SyncPermissionOnRoleRequest 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'       => 'admin',
22
        'permissions' => '',
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->hasAccess();
63
    }
64
}
65