<?php

namespace Modules\Order\Resources\Api;

use Illuminate\Http\Resources\Json\JsonResource;
use Modules\User\Resources\Api\ChildrenResource;

class OrderResource extends JsonResource
{

    /**
     * Transform the resource into an array.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return array
     */
    public function toArray($request)
    {
        return [
            'id' => (int) $this->id,
            'count' => (int) $this->count,
            'total' => (double) $this->total,
//            'total_points' => (double) $this->total_points,
            'total_management' => (double) $this->total_management,
            'tax_cost' => (double) $this->tax_cost,
            'total_products' => (double) $this->total_products,
            'date' => $this->getDateAttribute(),
            'child' => new ChildrenResource($this->child),
            'details' => OrderDetailsResource::collection($this->products)
        ];
    }

}
