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
InAppNotificationCampaignResource
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
 toArray
100.00% covered (success)
100.00%
32 / 32
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3namespace App\Http\Resources\v2;
4
5use Illuminate\Http\Request;
6use Illuminate\Http\Resources\Json\JsonResource;
7
8/**
9 * Resource for transforming InAppNotificationCampaign models for admin API responses.
10 *
11 * @property string $_id
12 * @property string $id_slug
13 * @property int $priority
14 * @property string $title
15 * @property string $body
16 * @property string|null $icon_url
17 * @property string|null $image_url
18 * @property string|null $iframe_url
19 * @property int|null $iframe_width
20 * @property int|null $iframe_height
21 * @property string|null $cta_text
22 * @property string|null $cta_url
23 * @property string|null $cta_action
24 * @property string|null $secondary_cta_text
25 * @property string|null $secondary_cta_url
26 * @property string|null $accent_color
27 * @property string $display_mode
28 * @property string|null $position
29 * @property array|null $target_urls
30 * @property bool $requires_auth
31 * @property array|null $target_plans
32 * @property int|null $max_impressions
33 * @property int|null $cooldown_hours
34 * @property \Carbon\Carbon|null $start_date
35 * @property \Carbon\Carbon|null $end_date
36 * @property int|null $auto_dismiss_seconds
37 * @property string|null $tracking_event
38 * @property bool $is_active
39 * @property \Carbon\Carbon|null $created_at
40 * @property \Carbon\Carbon|null $updated_at
41 */
42class InAppNotificationCampaignResource extends JsonResource
43{
44    /**
45     * Transform the resource into an array.
46     *
47     * @return array<string, mixed>
48     */
49    public function toArray(Request $request): array
50    {
51        return [
52            'id' => (string) $this->_id,
53            'id_slug' => $this->id_slug,
54            'priority' => (int) $this->priority,
55            'title' => $this->title,
56            'body' => $this->body,
57            'icon_url' => $this->icon_url,
58            'image_url' => $this->image_url,
59            'iframe_url' => $this->iframe_url,
60            'iframe_width' => $this->iframe_width,
61            'iframe_height' => $this->iframe_height,
62            'cta_text' => $this->cta_text,
63            'cta_url' => $this->cta_url,
64            'cta_action' => $this->cta_action,
65            'secondary_cta_text' => $this->secondary_cta_text,
66            'secondary_cta_url' => $this->secondary_cta_url,
67            'accent_color' => $this->accent_color,
68            'display_mode' => $this->display_mode,
69            'position' => $this->position,
70            'target_urls' => $this->target_urls,
71            'requires_auth' => (bool) $this->requires_auth,
72            'target_plans' => $this->target_plans,
73            'max_impressions' => $this->max_impressions,
74            'cooldown_hours' => $this->cooldown_hours,
75            'start_date' => $this->start_date?->timestamp,
76            'end_date' => $this->end_date?->timestamp,
77            'auto_dismiss_seconds' => $this->auto_dismiss_seconds,
78            'tracking_event' => $this->tracking_event,
79            'is_active' => (bool) $this->is_active,
80            'created_at' => $this->created_at?->timestamp,
81            'updated_at' => $this->updated_at?->timestamp,
82        ];
83    }
84}