PermissionByGroupRequest   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A rules() 0 13 1
1
<?php
2
3
namespace BBSLab\NovaPermission\Http\Requests;
4
5
use Illuminate\Validation\Rule;
6
7
/**
8
 * Class PermissionByGroupRequest.
9
 *
10
 * @property string|null $group
11
 */
12
class PermissionByGroupRequest extends PermissionRequest
13
{
14
    /**
15
     * Get the validation rules that apply to the request.
16
     *
17
     * @return array
18
     */
19
    public function rules()
20
    {
21
        return array_merge(parent::rules(), [
22
            'group' => [
23
                'nullable',
24
                'string',
25
                Rule::exists(config('permission.table_names.permissions'), 'group')
26
                    ->where(function ($query) {
27
                        $query->whereNull(['authorizable_id', 'authorizable_type']);
28
                    }),
29
            ],
30
        ]);
31
    }
32
}
33