<?php

namespace Modules\Order\Resources\Api;

use Illuminate\Http\Resources\Json\JsonResource;
use Modules\Product\Resources\Api\ProductResource;

class OrderDetailsResource extends JsonResource
{

    /**
     * Transform the resource into an array.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return array
     */
    public function toArray($request)
    {
        return [
            'id' => (int) $this->id,
            'order_id' => (int) $this->order_id,
            'count' => (int) $this->count,
            'product_cost' => (double) $this->product_cost,
            'product_total' => (double) $this->product_total,
            'product' => new ProductResource($this->product),
            'date' => $this->getDateAttribute(),
            'points' => (double) $this->points
        ];
    }

}
