UpdatePreferenceRequest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 3
eloc 11
c 1
b 0
f 1
dl 0
loc 32
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A authorize() 0 3 1
A messages() 0 7 1
A rules() 0 6 1
1
<?php
2
3
namespace Usamamuneerchaudhary\Notifier\Http\Requests;
4
5
use Illuminate\Foundation\Http\FormRequest;
6
7
class UpdatePreferenceRequest extends FormRequest
8
{
9
    /**
10
     * Determine if the user is authorized to make this request.
11
     */
12
    public function authorize(): bool
13
    {
14
        return true;
15
    }
16
17
    /**
18
     * Get the validation rules that apply to the request.
19
     */
20
    public function rules(): array
21
    {
22
        return [
23
            'channels' => ['required', 'array'],
24
            'channels.*' => ['boolean'],
25
            'settings' => ['sometimes', 'array'],
26
        ];
27
    }
28
29
    /**
30
     * Get custom messages for validator errors.
31
     */
32
    public function messages(): array
33
    {
34
        return [
35
            'channels.required' => 'The channels field is required.',
36
            'channels.array' => 'The channels must be an array.',
37
            'channels.*.boolean' => 'Each channel value must be a boolean (true/false).',
38
            'settings.array' => 'The settings must be an array.',
39
        ];
40
    }
41
}
42
43
44
45