<?php

namespace App\Http\Resources;

use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;

class NewsResource extends JsonResource
{
    public function toArray(Request $request): array
    {
        return [
            'id'           => $this->id,
            'title'        => $this->title,
            'summary'      => $this->summary,
            'image_url'    => $this->image_url,
            'external_url' => $this->external_url,
            'category'     => $this->category,
            'youtube_url'  => $this->youtube_url,
            'related_team' => $this->relatedTeam ? new TeamResource($this->relatedTeam) : null,
            'published_at' => $this->created_at?->toIso8601String(),
        ];
    }
}
