38 lines
1.2 KiB
PHP
38 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Endpoint\Api\Http\Resources;
|
|
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
|
|
class ProduckSkuResource extends JsonResource
|
|
{
|
|
/**
|
|
* Transform the resource into an array.
|
|
*
|
|
* @param \Illuminate\Http\Request $request
|
|
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
|
*/
|
|
public function toArray($request)
|
|
{
|
|
return [
|
|
'id' => $this->id,
|
|
'name' => $this->name,
|
|
'subtitle' => (string) $this->subtitle,
|
|
'cover' => (string) $this->cover,
|
|
'media' => (string) $this->media,
|
|
'images' => $this->images,
|
|
'sell_price' => (string) $this->sell_price_format,
|
|
'vip_price' => (string) $this->vip_price_format,
|
|
'sales' => $this->sales,
|
|
'description' => (string) $this->description,
|
|
'attrs' => $this->attrs,
|
|
'stock' => $this->saleable_stock,
|
|
'weight' => (int) $this->weight,
|
|
'is_online' => $this->isOnline(),
|
|
'buynote' => (string) $this->when($this->relationLoaded('buynote'), function () {
|
|
return $this->buynote?->content;
|
|
}),
|
|
];
|
|
}
|
|
}
|