<?php

namespace Sarga\API\Http\Resources\Core;

use Illuminate\Http\Resources\Json\JsonResource;
use Sarga\API\Http\Resources\Catalog\Category;
use Sarga\API\Http\Resources\Catalog\Review;

class VendorDetail extends JsonResource
{
    /**
     * Transform the resource into an array.
     *
     * @param  \Illuminate\Http\Request
     * @return array
     */
    public function toArray($request)
    {
        return [
            'id'         => $this->id,
            'url'        => $this->url,
            'shop_title' => $this->shop_title,
            'logo'       => $this->logo_url,
            'banner'     => $this->banner_url,
            'ship_price'     => $this->ship_price,
            'ship_time'     => $this->ship_time,
            'review_average' => $this->review_average,
            'slogan' => $this->slogan,
            $this->mergeWhen(!empty($this->main_categories) && $this->main_categories->count(),[
                'categories' => Category::collection($this->main_categories)
            ]),
            // 'reviews' => $this->reviews,


        ];
    }
}