34 lines
1.1 KiB
PHP
34 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace Modules\Mall\Http\Resources\Api\Goods;
|
|
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
use Modules\Mall\Http\Resources\Api\Shop\ShopBaseInfoResource;
|
|
|
|
class GoodsBaseResource extends JsonResource
|
|
{
|
|
|
|
public function toArray($request): array
|
|
{
|
|
return [
|
|
'goods_id' => $this->id,
|
|
'shop' => new ShopBaseInfoResource($this->shop),
|
|
'is_self' => (bool) $this->shop->is_self,
|
|
'name' => $this->name,
|
|
'description' => $this->description ?? '',
|
|
'cover' => $this->cover_url,
|
|
'tags' => TagResource::collection($this->tags),
|
|
'original_price' => (float) $this->original_price,
|
|
'price' => [
|
|
'show' => $this->price,
|
|
'score' => $this->score,
|
|
'price_min' => $this->price_min,
|
|
'price_max' => $this->price_max,
|
|
],
|
|
'clicks' => $this->clicks,
|
|
'sales' => $this->sales,
|
|
];
|
|
}
|
|
|
|
}
|