36 lines
1.2 KiB
PHP
36 lines
1.2 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace App\Http\Resources;
|
||
|
|
|
||
|
|
use Illuminate\Http\Request;
|
||
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
||
|
|
|
||
|
|
class ArticleResource extends JsonResource
|
||
|
|
{
|
||
|
|
/**
|
||
|
|
* Transform the resource into an array.
|
||
|
|
*
|
||
|
|
* @return array<string, mixed>
|
||
|
|
*/
|
||
|
|
public function toArray(Request $request): array
|
||
|
|
{
|
||
|
|
return [
|
||
|
|
'id' => $this->id,
|
||
|
|
'feed_id' => $this->feed_id,
|
||
|
|
'url' => $this->url,
|
||
|
|
'title' => $this->title,
|
||
|
|
'description' => $this->description,
|
||
|
|
'is_valid' => $this->is_valid,
|
||
|
|
'is_duplicate' => $this->is_duplicate,
|
||
|
|
'approval_status' => $this->approval_status,
|
||
|
|
'approved_at' => $this->approved_at?->toISOString(),
|
||
|
|
'approved_by' => $this->approved_by,
|
||
|
|
'fetched_at' => $this->fetched_at?->toISOString(),
|
||
|
|
'validated_at' => $this->validated_at?->toISOString(),
|
||
|
|
'created_at' => $this->created_at->toISOString(),
|
||
|
|
'updated_at' => $this->updated_at->toISOString(),
|
||
|
|
'feed' => new FeedResource($this->whenLoaded('feed')),
|
||
|
|
'article_publication' => new ArticlePublicationResource($this->whenLoaded('articlePublication')),
|
||
|
|
];
|
||
|
|
}
|
||
|
|
}
|