<?php

namespace App\Http\Resources\Api\Dashboard\Admin\Product;

use Illuminate\Http\Resources\Json\JsonResource;

class SimpleProductResource extends JsonResource
{
    /**
     * Transform the resource into an array.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
     */
    public function toArray($request)
    {
        
        return [
            'id'             => $this->id,
            'base_image'     => $this->base_image,
            'title'          => $this->title,
            'desc'           => $this->desc,
            'brand'          => $this->when($this->type == 'item', $this->brand),
            'serving_size'   => $this->serving_size,
            'size_of_cup'    => $this->size_of_cup,
            'calories'       => $this->calories,
            'calories_per'   => $this->calories_per,
            'is_organic'     => (bool) $this->is_organic,
            'is_saved'       => (bool) $this->is_saved,
            'is_liked'       => (bool) $this->is_liked,
            'is_shared'      => (bool) $this->is_shared,
            'likes_count'    => $this->likes_count,
            'shares_count'   => $this->shares_count,
        ];
    }
}
