PermissionRequest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 0
dl 0
loc 38
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A authorize() 0 4 1
A rules() 0 10 1
A searchValue() 0 4 1
1
<?php
2
3
namespace BBSLab\NovaPermission\Http\Requests;
4
5
use Illuminate\Foundation\Http\FormRequest;
6
use Illuminate\Validation\Rule;
7
8
/**
9
 * Class PermissionRequest.
10
 *
11
 * @property string $guard
12
 */
13
abstract class PermissionRequest extends FormRequest
14
{
15
    /**
16
     * Determine if the user is authorized to make this request.
17
     *
18
     * @return bool
19
     */
20
    public function authorize()
21
    {
22
        return true;
23
    }
24
25
    /**
26
     * Get the validation rules that apply to the request.
27
     *
28
     * @return array
29
     */
30
    public function rules()
31
    {
32
        return [
33
            'guard' => [
34
                'required',
35
                'string',
36
                Rule::in(array_keys(config('auth.guards'))),
37
            ],
38
        ];
39
    }
40
41
    /**
42
     * Get the query search value.
43
     *
44
     * @return string
45
     */
46
    public function searchValue(): string
47
    {
48
        return trim($this->query('search', ''));
49
    }
50
}
51