Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
12 / 12
100.00% covered (success)
100.00%
1 / 1
CRAP
100.00% covered (success)
100.00%
1 / 1
InAppNotificationResource
100.00% covered (success)
100.00%
12 / 12
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 toArray
100.00% covered (success)
100.00%
12 / 12
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 InAppNotification models for PATCH response.
10 *
11 * @property string $_id
12 * @property string $campaign_id
13 * @property string $user_id
14 * @property string $status
15 * @property \Carbon\Carbon|null $sent_at
16 * @property \Carbon\Carbon|null $viewed_at
17 * @property \Carbon\Carbon|null $clicked_at
18 * @property \Carbon\Carbon|null $dismissed_at
19 * @property int $impression_count
20 * @property \Carbon\Carbon|null $created_at
21 * @property \Carbon\Carbon|null $updated_at
22 */
23class InAppNotificationResource extends JsonResource
24{
25    /**
26     * Transform the resource into an array.
27     *
28     * @return array<string, mixed>
29     */
30    public function toArray(Request $request): array
31    {
32        return [
33            'id' => (string) $this->_id,
34            'campaign_id' => (string) $this->campaign_id,
35            'status' => $this->status,
36            'sent_at' => $this->sent_at?->timestamp,
37            'viewed_at' => $this->viewed_at?->timestamp,
38            'clicked_at' => $this->clicked_at?->timestamp,
39            'dismissed_at' => $this->dismissed_at?->timestamp,
40            'impression_count' => (int) $this->impression_count,
41            'created_at' => $this->created_at?->timestamp,
42            'updated_at' => $this->updated_at?->timestamp,
43        ];
44    }
45}