Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
31 / 31 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
| CreateInAppNotificationCampaignRequest | |
100.00% |
31 / 31 |
|
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
| rules | |
100.00% |
31 / 31 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace App\Http\Requests\v2\InAppNotification; |
| 4 | |
| 5 | use App\Http\Requests\v2\Parameter\Concerns\AuthorizesVengresoAdmin; |
| 6 | use Illuminate\Foundation\Http\FormRequest; |
| 7 | |
| 8 | /** |
| 9 | * Request for creating a new in-app notification campaign. |
| 10 | * |
| 11 | * @property string $id_slug Human-readable slug (e.g. "grammar-reengage-2026-q1") |
| 12 | * @property int $priority Display priority (lower = higher priority) |
| 13 | * @property string $title Notification title |
| 14 | * @property string $body Notification body text |
| 15 | * @property string|null $icon_url URL for the notification icon |
| 16 | * @property string|null $image_url URL for the notification image |
| 17 | * @property string|null $iframe_url URL for embedded iframe content |
| 18 | * @property int|null $iframe_width Width of embedded iframe in pixels |
| 19 | * @property int|null $iframe_height Height of embedded iframe in pixels |
| 20 | * @property string|null $cta_text Primary call-to-action button text |
| 21 | * @property string|null $cta_url Primary call-to-action URL |
| 22 | * @property string|null $cta_action Primary CTA action type |
| 23 | * @property string|null $secondary_cta_text Secondary CTA button text |
| 24 | * @property string|null $secondary_cta_url Secondary CTA URL |
| 25 | * @property string|null $accent_color Accent color hex code |
| 26 | * @property string $display_mode Display mode (banner, modal, toast, etc.) |
| 27 | * @property string|null $position Display position on screen |
| 28 | * @property array<string>|null $target_urls URL patterns where notification should appear |
| 29 | * @property bool $requires_auth Whether user must be authenticated (default: true) |
| 30 | * @property array<string>|null $target_plans Plan identifiers to target |
| 31 | * @property int|null $max_impressions Maximum impressions per user |
| 32 | * @property int|null $cooldown_hours Hours between re-showing to same user |
| 33 | * @property string|null $start_date Campaign start date (ISO 8601) |
| 34 | * @property string|null $end_date Campaign end date (ISO 8601) |
| 35 | * @property int|null $auto_dismiss_seconds Auto-dismiss after N seconds |
| 36 | * @property string|null $tracking_event Analytics tracking event name |
| 37 | * @property bool $is_active Whether campaign is active (default: true) |
| 38 | */ |
| 39 | class CreateInAppNotificationCampaignRequest extends FormRequest |
| 40 | { |
| 41 | use AuthorizesVengresoAdmin; |
| 42 | |
| 43 | /** |
| 44 | * Get the validation rules that apply to the request. |
| 45 | * |
| 46 | * @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string> |
| 47 | */ |
| 48 | public function rules(): array |
| 49 | { |
| 50 | return [ |
| 51 | 'id_slug' => 'required|string|max:255|unique:in_app_notification_campaigns,id_slug', |
| 52 | 'priority' => 'required|integer|min:1', |
| 53 | 'title' => 'required|string|max:255', |
| 54 | 'body' => 'required|string|max:2000', |
| 55 | 'icon_url' => 'sometimes|nullable|string|max:2048', |
| 56 | 'image_url' => 'sometimes|nullable|string|max:2048', |
| 57 | 'iframe_url' => 'sometimes|nullable|string|max:2048', |
| 58 | 'iframe_width' => 'sometimes|nullable|integer|min:100|max:2000', |
| 59 | 'iframe_height' => 'sometimes|nullable|integer|min:100|max:2000', |
| 60 | 'cta_text' => 'sometimes|nullable|string|max:100', |
| 61 | 'cta_url' => 'sometimes|nullable|string|max:2048', |
| 62 | 'cta_action' => 'sometimes|nullable|string|max:100', |
| 63 | 'secondary_cta_text' => 'sometimes|nullable|string|max:100', |
| 64 | 'secondary_cta_url' => 'sometimes|nullable|string|max:2048', |
| 65 | 'accent_color' => 'sometimes|nullable|string|max:20', |
| 66 | 'display_mode' => 'required|string|max:50', |
| 67 | 'position' => 'sometimes|nullable|string|max:50', |
| 68 | 'target_urls' => 'sometimes|nullable|array', |
| 69 | 'target_urls.*' => 'string|max:2048', |
| 70 | 'requires_auth' => 'sometimes|boolean', |
| 71 | 'target_plans' => 'sometimes|nullable|array', |
| 72 | 'target_plans.*' => 'string|max:255', |
| 73 | 'max_impressions' => 'sometimes|nullable|integer|min:1', |
| 74 | 'cooldown_hours' => 'sometimes|nullable|integer|min:1', |
| 75 | 'start_date' => 'sometimes|nullable|date', |
| 76 | 'end_date' => 'sometimes|nullable|date|after_or_equal:start_date', |
| 77 | 'auto_dismiss_seconds' => 'sometimes|nullable|integer|min:1', |
| 78 | 'tracking_event' => 'sometimes|nullable|string|max:255', |
| 79 | 'is_active' => 'sometimes|boolean', |
| 80 | ]; |
| 81 | } |
| 82 | } |