<?php

namespace Modules\Mall\Http\Resources\Api\Goods;

use Illuminate\Http\Resources\Json\JsonResource;

class CartResource extends JsonResource
{

    public function toArray($request): array
    {
        return [
            'cart_id'  => $this->id,
            'sku_id'   => $this->sku_id,
            'goods_id' => $this->sku->goods_id,
            'qty'      => $this->qty,
            'max_qty'  => $this->sku->stock,
            'price'    => (float) $this->sku->price,
            'cover'    => $this->sku->cover_url,
            'name'     => $this->sku->goods->name,
        ];
    }

}