Code Duplication    Length = 54-55 lines in 9 locations

app/Containers/Authorization/UI/API/Requests/AttachPermissionToRoleRequest.php 1 location

@@ 12-66 (lines=55) @@
9
 *
10
 * @author Mahmoud Zalt <[email protected]>
11
 */
12
class AttachPermissionToRoleRequest 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->check([
63
            'hasAccess',
64
        ]);
65
    }
66
}
67

app/Containers/Authorization/UI/API/Requests/CreatePermissionRequest.php 1 location

@@ 12-65 (lines=54) @@
9
 *
10
 * @author Mahmoud Zalt <[email protected]>
11
 */
12
class CreatePermissionRequest 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
32
    ];
33
34
    /**
35
     * Defining the URL parameters (`/stores/999/items`) allows applying
36
     * validation rules on them and allows accessing them like request data.
37
     *
38
     * @var  array
39
     */
40
    protected $urlParameters = [
41
42
    ];
43
44
    /**
45
     * @return  array
46
     */
47
    public function rules()
48
    {
49
        return [
50
            'name'         => 'required|unique:permissions,name|max:100',
51
            'description'  => 'max:255',
52
            'display_name' => 'max:100',
53
        ];
54
    }
55
56
    /**
57
     * @return  bool
58
     */
59
    public function authorize()
60
    {
61
        return $this->check([
62
            'hasAccess',
63
        ]);
64
    }
65
}
66

app/Containers/Authorization/UI/API/Requests/CreateRoleRequest.php 1 location

@@ 13-66 (lines=54) @@
10
 *
11
 * @author Mahmoud Zalt <[email protected]>
12
 */
13
class CreateRoleRequest extends Request
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

app/Containers/Authorization/UI/API/Requests/DetachPermissionToRoleRequest.php 1 location

@@ 12-66 (lines=55) @@
9
 *
10
 * @author Mahmoud Zalt <[email protected]>
11
 */
12
class DetachPermissionToRoleRequest 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
        'role_id',
32
        'permissions_ids.*',
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
            'role_id'           => 'required|exists:roles,id',
52
            'permissions_ids'   => 'required',
53
            'permissions_ids.*' => 'exists:permissions,id',
54
        ];
55
    }
56
57
    /**
58
     * @return  bool
59
     */
60
    public function authorize()
61
    {
62
        return $this->check([
63
            'hasAccess',
64
        ]);
65
    }
66
}
67

app/Containers/Authorization/UI/API/Requests/RevokeUserFromRoleRequest.php 1 location

@@ 12-66 (lines=55) @@
9
 *
10
 * @author Mahmoud Zalt <[email protected]>
11
 */
12
class RevokeUserFromRoleRequest 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
        'roles_ids.*',
32
        'user_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
            'roles_ids'   => 'required',
52
            'roles_ids.*' => 'exists:roles,id',
53
            'user_id'     => 'required|exists:users,id',
54
        ];
55
    }
56
57
    /**
58
     * @return  bool
59
     */
60
    public function authorize()
61
    {
62
        return $this->check([
63
            'hasAccess',
64
        ]);
65
    }
66
}
67

app/Containers/Authorization/UI/API/Requests/SyncPermissionsOnRoleRequest.php 1 location

@@ 12-66 (lines=55) @@
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'       => '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->check([
63
            'hasAccess',
64
        ]);
65
    }
66
}
67

app/Containers/Authorization/UI/API/Requests/SyncUserRolesRequest.php 1 location

@@ 12-66 (lines=55) @@
9
 *
10
 * @author Mahmoud Zalt <[email protected]>
11
 */
12
class SyncUserRolesRequest 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
        'user_id',
32
        'roles_ids.*',
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
            'roles_ids'   => 'required',
52
            'roles_ids.*' => 'exists:roles,id',
53
            'user_id'     => 'required|exists:users,id',
54
        ];
55
    }
56
57
    /**
58
     * @return  bool
59
     */
60
    public function authorize()
61
    {
62
        return $this->check([
63
            'hasAccess',
64
        ]);
65
    }
66
}
67

app/Containers/User/UI/API/Requests/CreateAdminRequest.php 1 location

@@ 12-65 (lines=54) @@
9
 *
10
 * @author Mahmoud Zalt <[email protected]>
11
 */
12
class CreateAdminRequest 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
        'permissions' => '',
22
        'roles'       => 'admin',
23
    ];
24
25
    /**
26
     * Id's that needs decoding before applying the validation rules.
27
     *
28
     * @var  array
29
     */
30
    protected $decode = [
31
32
    ];
33
34
    /**
35
     * Defining the URL parameters (`/stores/999/items`) allows applying
36
     * validation rules on them and allows accessing them like request data.
37
     *
38
     * @var  array
39
     */
40
    protected $urlParameters = [
41
42
    ];
43
44
    /**
45
     * @return  array
46
     */
47
    public function rules()
48
    {
49
        return [
50
            'email'    => 'required|email|max:40|unique:users,email',
51
            'password' => 'required|min:3|max:30',
52
            'name'     => 'min:2|max:50',
53
        ];
54
    }
55
56
    /**
57
     * @return  bool
58
     */
59
    public function authorize()
60
    {
61
        return $this->check([
62
            'hasAccess',
63
        ]);
64
    }
65
}
66

app/Containers/User/UI/API/Requests/RegisterUserRequest.php 1 location

@@ 12-65 (lines=54) @@
9
 *
10
 * @author Mahmoud Zalt <[email protected]>
11
 */
12
class RegisterUserRequest 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
        'permissions' => '',
22
        'roles'       => '',
23
    ];
24
25
    /**
26
     * Id's that needs decoding before applying the validation rules.
27
     *
28
     * @var  array
29
     */
30
    protected $decode = [
31
32
    ];
33
34
    /**
35
     * Defining the URL parameters (`/stores/999/items`) allows applying
36
     * validation rules on them and allows accessing them like request data.
37
     *
38
     * @var  array
39
     */
40
    protected $urlParameters = [
41
42
    ];
43
44
    /**
45
     * @return  array
46
     */
47
    public function rules()
48
    {
49
        return [
50
            'email'    => 'required|email|max:40|unique:users,email',
51
            'password' => 'required|min:6|max:30',
52
            'name'     => 'required|min:2|max:50',
53
        ];
54
    }
55
56
    /**
57
     * @return  bool
58
     */
59
    public function authorize()
60
    {
61
        return $this->check([
62
            'hasAccess',
63
        ]);
64
    }
65
}
66