32 lines
1.1 KiB
PHP
32 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Api\Resources;
|
|
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
|
|
class GoodsParamsListResource extends JsonResource
|
|
{
|
|
/**
|
|
* Transform the resource into an array.
|
|
*
|
|
* @param \Illuminate\Http\Request $request
|
|
* @return array
|
|
*/
|
|
public function toArray($request)
|
|
{
|
|
return [
|
|
'id' => $this->goods_id,
|
|
'title' => $this->goods->title,
|
|
'img' => $this->goods->storage_id ? $this->goods->storage ? 'http://www.bohaimingpin.com' . $this->storage->path : '' : '',
|
|
'price' => number_format($this->price - $this->score,2),
|
|
'score' => number_format($this->score,2),
|
|
'original' => number_format($this->original,2),
|
|
'stock' => $this->stock,
|
|
'description' => mb_substr($this->goods->description, 0, 60),
|
|
'tag'=> $this->score == 0 ? '现金购' : $this->price == $this->score ? '积分购' : '积分+现金购',
|
|
'type'=> $this->score == 0 ? 'cash' : $this->price == $this->score ? 'score' : 'cashScore'
|
|
|
|
];
|
|
}
|
|
}
|