PermissionByAuthorizableRequest::rules()   A
last analyzed

Complexity

Conditions 2
Paths 1

Size

Total Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 15
rs 9.7666
c 0
b 0
f 0
cc 2
nc 1
nop 0
1
<?php
2
3
namespace BBSLab\NovaPermission\Http\Requests;
4
5
/**
6
 * Class PermissionByAuthorizableRequest.
7
 *
8
 * @property int $id
9
 * @property string $type
10
 */
11
class PermissionByAuthorizableRequest extends PermissionRequest
12
{
13
    /**
14
     * Get the validation rules that apply to the request.
15
     *
16
     * @return array
17
     */
18
    public function rules()
19
    {
20
        return array_merge(parent::rules(), [
21
            'id' => 'required',
22
            'type' => [
23
                'required',
24
                'string',
25
                function ($attribute, $value, $fail) {
26
                    if (! class_exists($value)) {
27
                        $fail($attribute.'is invalid');
28
                    }
29
                },
30
            ],
31
        ]);
32
    }
33
}
34