SettingRequest::prepareForValidation()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 3
nc 2
nop 0
dl 0
loc 5
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Pratiksh\Adminetic\Http\Requests;
4
5
use Illuminate\Foundation\Http\FormRequest;
6
7
class SettingRequest extends FormRequest
8
{
9
    /**
10
     * Determine if the user is authorized to make this request.
11
     *
12
     * @return bool
13
     */
14
    public function authorize()
15
    {
16
        return true;
17
    }
18
19
    /**
20
     * Prepare the data for validation.
21
     *
22
     * @return void
23
     */
24
    protected function prepareForValidation()
25
    {
26
        if (isset(request()->new_setting_group)) {
27
            $this->merge([
28
                'setting_group' => strtolower(str_replace(' ', '_', request()->new_setting_group)),
29
            ]);
30
        }
31
    }
32
33
    /**
34
     * Get the validation rules that apply to the request.
35
     *
36
     * @return array
37
     */
38
    public function rules()
39
    {
40
        return [
41
            'setting_name' => 'required|max:255',
42
            'string_value' => 'nullable|max:255',
43
            'integer_value' => 'nullable|numeric',
44
            'text_value' => 'nullable|max:65000',
45
            'boolean_value' => 'nullable|boolean',
46
            'setting_type' => 'required|numeric',
47
            'setting_group' => 'required|max:20',
48
            'setting_custom' => 'nullable',
49
        ];
50
    }
51
}
52