Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 36 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 1 |
SettingFormRequest | |
0.00% |
0 / 36 |
|
0.00% |
0 / 3 |
30 | |
0.00% |
0 / 1 |
authorize | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
rules | |
0.00% |
0 / 32 |
|
0.00% |
0 / 1 |
12 | |||
messages | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | |
3 | namespace App\Http\Requests; |
4 | |
5 | use Illuminate\Foundation\Http\FormRequest; |
6 | |
7 | class SettingFormRequest extends FormRequest |
8 | { |
9 | public function authorize(): bool |
10 | { |
11 | return true; |
12 | } |
13 | |
14 | public function rules(): array |
15 | { |
16 | $rules = []; |
17 | switch ($this->method()) { |
18 | case 'POST': |
19 | $rules = [ |
20 | 'shortcut_timeout' => 'required|integer', |
21 | 'blocked_domains' => 'sometimes|array|min:0', |
22 | 'blocked_domains.*' => 'sometimes|string|url|distinct|min:0', |
23 | ]; |
24 | break; |
25 | |
26 | case 'PUT': |
27 | $rules = [ |
28 | 'shortcut_timeout' => 'sometimes|required|integer', |
29 | 'blocked_domains' => 'sometimes|array|min:0', |
30 | 'blocked_domains.*' => 'sometimes|string|url|distinct|min:0', |
31 | 'fly_rewrite' => 'sometimes|in:enabled,disabled', |
32 | 'fly_rewrite_blocked_domains' => 'sometimes|array', |
33 | 'fly_rewrite_blocked_domains.*' => 'sometimes|string|min:0', |
34 | 'fly_grammar' => 'sometimes|in:enabled,disabled', |
35 | 'fly_grammar_blocked_domains' => 'sometimes|array', |
36 | 'fly_grammar_blocked_domains.*' => 'sometimes|string|min:0', |
37 | 'words_per_minute' => 'sometimes|integer|min:1', |
38 | 'wage_per_hour' => 'sometimes|integer|min:1', |
39 | 'typing_style' => 'sometimes|string|in:word,letter,all', |
40 | 'typing_speed' => 'sometimes|nullable|integer|min:20|max:60', |
41 | 'fly_grammar_default_language' => 'sometimes|nullable|string', |
42 | 'upgrade_coupon_order_displayed' => 'sometimes|nullable|integer', |
43 | 'custom_prompts_order_flyengage' => 'sometimes|nullable|array', |
44 | 'custom_prompts_order_flypost' => 'sometimes|nullable|array', |
45 | 'custom_fly_write_order' => 'sometimes|nullable|array', |
46 | ]; |
47 | break; |
48 | } |
49 | |
50 | return $rules; |
51 | } |
52 | |
53 | public function messages(): array |
54 | { |
55 | return [ |
56 | 'blocked_domains.*.url' => 'Domain format is invalid.', |
57 | ]; |
58 | } |
59 | } |