24 lines
659 B
PHP
24 lines
659 B
PHP
<?php
|
|
|
|
namespace Modules\Mall\Http\Resources\Api\Goods;
|
|
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
use Modules\Mall\Models\Goods;
|
|
|
|
class DetailResource extends JsonResource
|
|
{
|
|
|
|
public function toArray($request): array
|
|
{
|
|
return [
|
|
'cart_id' => $this->id,
|
|
'sku_id' => $this->sku_id,
|
|
'qty' => $this->qty,
|
|
'max_qty' => $this->sku->stock,
|
|
'price' => (float) $this->sku->price,
|
|
'cover' => ($this->sku->goods->type === Goods::TYPE_SINGLE) ? $this->sku->goods->cover_url : $this->sku->cover_url,
|
|
'name' => $this->sku->goods->name,
|
|
];
|
|
}
|
|
|
|
} |