<?php

namespace Modules\Banner\Models\Resources;

use Illuminate\Http\Resources\Json\JsonResource;
use Modules\Category\Models\Resources\CategoryResource;
use Modules\Type\Models\Resources\TypeResource;

class BannerResource extends JsonResource
{
    /**
     * Transform the resource into an array.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return array
     */
    public function toArray($request)
    {
        return [
            'id' => $this->id,
            'active_status' => $this->active_status,
            'show_all_pages' => $this->show_all_pages,
            'count_photo' => $this->count_photo,
            'type'=>new TypeResource($this->whenLoaded('type')),
            'category'=>new CategoryResource($this->whenLoaded('category')),
            'photos'=>BannerPhotoResource::collection($this->whenLoaded('photos')),
        ];
    }
}
