<?php

namespace App\Http\Controllers\Api\V1\Story\Resources;

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

class StoryResource extends JsonResource
{
    /**
     * Transform the resource into an array.
     *
     * @return array<string, mixed>
     */
    public function toArray(Request $request): array
    {
        return [
            'id' => $this->whenHas('id'),
            'title' => $this->whenHas('title'),
            'photo' => $this->photo(),
            'thumbnail' => $this->photo('thumb720x1280'),
            'expires_at' => $this->expires_at?->toISOString(),
        ];
    }
}
