You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
1.1 KiB
42 lines
1.1 KiB
<?php
|
|
|
|
namespace App\Http\Resources;
|
|
|
|
use Illuminate\Http\Resources\Json\Resource;
|
|
|
|
class Good extends Resource
|
|
{
|
|
/**
|
|
* Transform the resource into an array.
|
|
*
|
|
* @param \Illuminate\Http\Request $request
|
|
* @return array
|
|
*/
|
|
public function toArray($request)
|
|
{
|
|
|
|
if (!empty($this->goods_description_pictures)) {
|
|
$pic = $this->goods_description_pictures;
|
|
foreach ($pic as $eachPic) {
|
|
$pics[] = [
|
|
'pic' => config('filesystems.disks.oss.url').'/'.$eachPic
|
|
];
|
|
}
|
|
} else {
|
|
$pics[] = [
|
|
'pic' => config('filesystems.disks.oss.url').'/'.$this->goods_main_image
|
|
];
|
|
}
|
|
return [
|
|
'id' => $this->id,
|
|
'pics' => $pics,
|
|
'name' => $this->goods_name,
|
|
'minPrice' => $this->goods_price,
|
|
'originalPrice' => $this->goods_marketprice,
|
|
'numberOrders' => $this->goods_salenum,
|
|
'pic' => config('filesystems.disks.oss.url').'/'.$this->goods_main_image,
|
|
'stores' => $this->goods_storage,
|
|
];
|
|
}
|
|
}
|