Passed
Push — develop ( c3d6a0...515348 )
by Septianata
14:35
created

UpdateRequest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 8
c 1
b 0
f 0
dl 0
loc 29
ccs 8
cts 8
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A rules() 0 5 1
A authorize() 0 3 1
A attributes() 0 5 1
1
<?php
2
3
namespace App\Http\Requests\Role;
4
5
use App\Infrastructure\Foundation\Http\FormRequest;
6
use App\Models\Role;
7
use Illuminate\Validation\Rule;
8
9
class UpdateRequest extends FormRequest
10
{
11
    /**
12
     * {@inheritDoc}
13
     */
14 1
    public function authorize()
15
    {
16 1
        return $this->user()->hasRole(Role::ROLE_ADMIN);
17
    }
18
19
    /**
20
     * {@inheritDoc}
21
     */
22 1
    public function rules()
23
    {
24
        return [
25 1
            'name' => ['required', 'string', 'max:255', Rule::unique(Role::class)->ignoreModel($this->route('role'))],
26 1
            'guard_name' => ['required', 'string', Rule::in(array_keys(config('auth.guards')))],
27
        ];
28
    }
29
30
    /**
31
     * {@inheritDoc}
32
     */
33 1
    public function attributes()
34
    {
35
        return [
36 1
            'name' => trans('Name'),
37 1
            'guard_name' => trans('Guard Name'),
38
        ];
39
    }
40
}
41