<?php

namespace App\Http\Resources\Api\App\DietPlan;

use Illuminate\Http\Resources\Json\JsonResource;
use App\Http\Resources\Api\App\Meal\MealResource;
use App\Http\Resources\Api\Dashboard\Admin\Product\SimpleProductResource;

class ItemDetailResource 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'                   => (int) $this->id,
            'product'              => SimpleProductResource::make($this->product),
            'number_of_servings'   => (int) $this->number_of_servings,
            'calories'             => (int) $this->calories,
            'fat'                  => (float) $this->fat,
            'protein'              => (float) $this->protein,
            'carb'                 => (float) $this->carb,
        ];
    }
}
