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