Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
52 / 52 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
| UpdateGlobalSettingsRequest | |
100.00% |
52 / 52 |
|
100.00% |
2 / 2 |
2 | |
100.00% |
1 / 1 |
| rules | |
100.00% |
45 / 45 |
|
100.00% |
1 / 1 |
1 | |||
| messages | |
100.00% |
7 / 7 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace App\Http\Requests\v2\GlobalSettings; |
| 4 | |
| 5 | use App\Http\Requests\v2\Parameter\Concerns\AuthorizesVengresoAdmin; |
| 6 | use Illuminate\Foundation\Http\FormRequest; |
| 7 | |
| 8 | /** |
| 9 | * Request for updating global settings (partial update supported). |
| 10 | * |
| 11 | * All fields are optional - only provided fields will be updated. |
| 12 | * For nested objects like features, provided values are merged with existing values. |
| 13 | * |
| 14 | * @property float|null $wage_per_hour Average hourly wage for calculations (min: 0) |
| 15 | * @property int|null $words_per_minute Typing speed in words per minute (min: 1) |
| 16 | * @property string|null $typing_style The typing style setting |
| 17 | * @property int|null $typing_speed The typing speed value (min: 1) |
| 18 | * @property bool|null $remove_grammar_on_lose_focus Whether to remove grammar on focus loss |
| 19 | * @property string|null $fly_rewrite FlyRewrite feature status ('enabled'/'disabled') |
| 20 | * @property string|null $fly_grammar FlyGrammar feature status ('enabled'/'disabled') |
| 21 | * @property string|null $fly_grammar_default_language Default language for FlyGrammar |
| 22 | * @property array{flyCuts?: bool, flyGrammar?: bool, gmailPlugin?: bool, linkedinPlugin?: bool, flyPosts?: bool, flyEngage?: bool, outlookPlugin?: bool, developerMode?: bool}|null $features Feature flags (partial update) |
| 23 | * @property array<string, array{title: string, link: string, description: string}>|null $playlists Playlist configurations (replaces all playlists) |
| 24 | * @property array<string>|null $ignoredInputTypes Input types to ignore (replaces all) |
| 25 | * @property array<string>|null $blackListClasses CSS classes to blacklist (replaces all) |
| 26 | * @property array<string>|null $blackListIds Element IDs to blacklist (replaces all) |
| 27 | * @property array<array{name: string, value: string}>|null $blackListAttributes Attribute name/value pairs to blacklist (replaces all) |
| 28 | * @property array<array{domain: string, blackListClasses: array, blackListIds: array, blackListAttributes: array}>|null $blackListDomainRules Domain-specific blacklist rules (replaces all) |
| 29 | */ |
| 30 | class UpdateGlobalSettingsRequest extends FormRequest |
| 31 | { |
| 32 | use AuthorizesVengresoAdmin; |
| 33 | |
| 34 | /** |
| 35 | * Get the validation rules that apply to the request. |
| 36 | * |
| 37 | * @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string> |
| 38 | */ |
| 39 | public function rules(): array |
| 40 | { |
| 41 | return [ |
| 42 | // Core settings |
| 43 | 'wage_per_hour' => 'sometimes|numeric|min:0', |
| 44 | 'words_per_minute' => 'sometimes|integer|min:1', |
| 45 | 'typing_style' => 'sometimes|string|max:50', |
| 46 | 'typing_speed' => 'sometimes|integer|min:1', |
| 47 | 'remove_grammar_on_lose_focus' => 'sometimes|boolean', |
| 48 | |
| 49 | // Feature toggles |
| 50 | 'fly_rewrite' => 'sometimes|string|in:enabled,disabled', |
| 51 | 'fly_grammar' => 'sometimes|string|in:enabled,disabled', |
| 52 | 'fly_grammar_default_language' => 'sometimes|string|max:10', |
| 53 | |
| 54 | // Feature flags (partial update supported) |
| 55 | 'features' => 'sometimes|array', |
| 56 | 'features.flyCuts' => 'sometimes|boolean', |
| 57 | 'features.flyGrammar' => 'sometimes|boolean', |
| 58 | 'features.gmailPlugin' => 'sometimes|boolean', |
| 59 | 'features.linkedinPlugin' => 'sometimes|boolean', |
| 60 | 'features.flyPosts' => 'sometimes|boolean', |
| 61 | 'features.flyEngage' => 'sometimes|boolean', |
| 62 | 'features.outlookPlugin' => 'sometimes|boolean', |
| 63 | 'features.developerMode' => 'sometimes|boolean', |
| 64 | |
| 65 | // Playlists |
| 66 | 'playlists' => 'sometimes|array', |
| 67 | 'playlists.*' => 'array', |
| 68 | 'playlists.*.title' => 'required_with:playlists.*|string|max:255', |
| 69 | 'playlists.*.link' => 'required_with:playlists.*|string|url|max:500', |
| 70 | 'playlists.*.description' => 'required_with:playlists.*|string|max:1000', |
| 71 | |
| 72 | // Blacklists |
| 73 | 'ignoredInputTypes' => 'sometimes|array', |
| 74 | 'ignoredInputTypes.*' => 'string|max:50', |
| 75 | |
| 76 | 'blackListClasses' => 'sometimes|array', |
| 77 | 'blackListClasses.*' => 'string|max:100', |
| 78 | |
| 79 | 'blackListIds' => 'sometimes|array', |
| 80 | 'blackListIds.*' => 'string|max:100', |
| 81 | |
| 82 | 'blackListAttributes' => 'sometimes|array', |
| 83 | 'blackListAttributes.*' => 'array', |
| 84 | 'blackListAttributes.*.name' => 'required_with:blackListAttributes.*|string|max:100', |
| 85 | 'blackListAttributes.*.value' => 'required_with:blackListAttributes.*|string|max:255', |
| 86 | |
| 87 | 'blackListDomainRules' => 'sometimes|array', |
| 88 | 'blackListDomainRules.*' => 'array', |
| 89 | 'blackListDomainRules.*.domain' => 'required_with:blackListDomainRules.*|string|max:255', |
| 90 | 'blackListDomainRules.*.blackListClasses' => 'sometimes|array', |
| 91 | 'blackListDomainRules.*.blackListClasses.*' => 'string|max:100', |
| 92 | 'blackListDomainRules.*.blackListIds' => 'sometimes|array', |
| 93 | 'blackListDomainRules.*.blackListIds.*' => 'string|max:100', |
| 94 | 'blackListDomainRules.*.blackListAttributes' => 'sometimes|array', |
| 95 | 'blackListDomainRules.*.blackListAttributes.*' => 'array', |
| 96 | 'blackListDomainRules.*.blackListAttributes.*.name' => 'required|string|max:100', |
| 97 | 'blackListDomainRules.*.blackListAttributes.*.value' => 'required|string|max:255', |
| 98 | ]; |
| 99 | } |
| 100 | |
| 101 | /** |
| 102 | * Get custom messages for validator errors. |
| 103 | * |
| 104 | * @return array<string, string> |
| 105 | */ |
| 106 | public function messages(): array |
| 107 | { |
| 108 | return [ |
| 109 | 'wage_per_hour.min' => 'The wage per hour must be a positive number.', |
| 110 | 'words_per_minute.min' => 'The words per minute must be at least 1.', |
| 111 | 'fly_rewrite.in' => 'The fly rewrite status must be either enabled or disabled.', |
| 112 | 'fly_grammar.in' => 'The fly grammar status must be either enabled or disabled.', |
| 113 | 'playlists.*.link.url' => 'Each playlist must have a valid URL.', |
| 114 | ]; |
| 115 | } |
| 116 | } |