<?php

namespace App\Http\Resources\V1\Favourites;

use App\Http\Resources\V1\ArtistResource;
use Illuminate\Http\Resources\Json\JsonResource;
use App\Http\Resources\V1\ImageResource;
use App\Http\Resources\V1\LocationResource;
use App\Models\Exhibition;

class FavouriteExhibitionResource extends JsonResource
{



    public function __construct(Exhibition $resource)
    {
        parent::__construct($resource);
    }

    /**
     * Transform the resource into an array.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return array
     */
    public function toArray($request)
    {

        $out = [
            'id'         => $this->id,
            'type'       => 'exhibition',
            'name'       => $this->title,
            'date_from'  => $this->date_from,
            'date_to'    => $this->date_to,
            'dateStatus' => $this->date_status,
            'image'      => new ImageResource($this->whenLoaded('image')),
            'artists'    => ArtistResource::collection($this->whenLoaded('artists')),
            'locations'  => new LocationResource($this->whenLoaded('location')),
            'share_url'  => $this->share_url,

        ];



        return $out;
    }
}
