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

UpdateRequest::attributes()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 4
c 1
b 0
f 0
dl 0
loc 6
ccs 4
cts 4
cp 1
rs 10
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
namespace App\Http\Requests\Configuration;
4
5
use App\Infrastructure\Foundation\Http\FormRequest;
6
use App\Models\Configuration;
7
use App\Models\Role;
8
use Illuminate\Validation\Rule;
9
10
class UpdateRequest extends FormRequest
11
{
12
    /**
13
     * {@inheritDoc}
14
     */
15 1
    public function authorize()
16
    {
17 1
        return $this->user()->hasRole(Role::ROLE_ADMIN);
18
    }
19
20
    /**
21
     * {@inheritDoc}
22
     */
23 1
    public function rules()
24
    {
25
        return [
26 1
            'key' => ['required', 'string', 'max:255', Rule::unique(Configuration::class)->ignoreModel($this->route('configuration'))],
27 1
            'value' => 'required|string|max:255',
28 1
            'description' => 'sometimes|nullable|string',
29
        ];
30
    }
31
32
    /**
33
     * {@inheritDoc}
34
     */
35 1
    public function attributes()
36
    {
37
        return [
38 1
            'key' => trans('Key'),
39 1
            'value' => trans('Value'),
40 1
            'description' => trans('Description'),
41
        ];
42
    }
43
}
44