<?php

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

use Illuminate\Http\Resources\Json\JsonResource;

class SkuResource extends JsonResource
{

    public function toArray($request): array
    {
        return [
            'sku_id'     => $this->id,
            'goods_id'   => $this->goods_id,
            'goods_name' => $this->goods->name,
            'cover'      => $this->cover_url,
            'price'      => (float) $this->price,
            'score'      => (float) $this->score,
            'assets'     => (float) $this->assets,
            'unit'       => $this->unit ?? '',
            'stock'      => $this->stock,
            'weight'     => $this->weight,
        ];
    }

}
