Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 18
0.00% covered (danger)
0.00%
0 / 1
CRAP
0.00% covered (danger)
0.00%
0 / 1
ArticleResource
0.00% covered (danger)
0.00%
0 / 18
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 1
 toArray
0.00% covered (danger)
0.00%
0 / 18
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2
3namespace App\Http\Resources;
4
5use Illuminate\Http\Request;
6use Illuminate\Http\Resources\Json\JsonResource;
7
8class ArticleResource extends JsonResource
9{
10    /**
11     * Transform the resource into an array.
12     *
13     * @return array<string, mixed>
14     */
15    public function toArray(Request $request): array
16    {
17        return [
18            'id' => $this->id,
19            'feed_id' => $this->feed_id,
20            'url' => $this->url,
21            'title' => $this->title,
22            'description' => $this->description,
23            'is_valid' => $this->is_valid,
24            'is_duplicate' => $this->is_duplicate,
25            'approval_status' => $this->approval_status,
26            'approved_at' => $this->approved_at?->toISOString(),
27            'approved_by' => $this->approved_by,
28            'fetched_at' => $this->fetched_at?->toISOString(),
29            'validated_at' => $this->validated_at?->toISOString(),
30            'created_at' => $this->created_at->toISOString(),
31            'updated_at' => $this->updated_at->toISOString(),
32            'feed' => new FeedResource($this->whenLoaded('feed')),
33            'article_publication' => new ArticlePublicationResource($this->whenLoaded('articlePublication')),
34        ];
35    }
36}