<?php

namespace App\Http\Resources\Gallery;

use Illuminate\Http\Resources\Json\JsonResource;

class GalleryDetail extends JsonResource
{
    /**
     * Transform the resource into an array.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return array
     */
    public function toArray($request)
    {
        $out = [
            'uid'             => $this->uid,
            'name'            => $this->name,
            'description'     => $this->description,
            'isFavourite'     => $this->is_favourite,
            'state'           => $this->state,
            'headerImage'     => $this->header_image,
            'headerSettings'  => $this->header_settings,
            'createdAt'       => $this->created_at,
            'sections'        => GallerySection::collection($this->whenLoaded('gallerySections')),
            // 'items'           => GalleryItem::collection($this->whenLoaded('galleryItems', $this->galleryItems, []))
            // TODO Thumbnail
        ];

        return $out;
    }
}
