43 lines
1.5 KiB
PHP
43 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace App\Api\Resources;
|
|
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
|
|
class GoodsParamsScoreDetailResource extends JsonResource
|
|
{
|
|
/**
|
|
* Transform the resource into an array.
|
|
*
|
|
* @param \Illuminate\Http\Request $request
|
|
* @return array
|
|
*/
|
|
public function toArray($request)
|
|
{
|
|
return [
|
|
'info'=>[
|
|
'id' => $this->id,
|
|
'title' => $this->title,
|
|
'img' => $this->storage_id ? $this->storage ? 'http://www.bohaimingpin.com'.$this->storage->path : '' : '',
|
|
'price'=> 0,
|
|
'score'=> $this->max_score ,
|
|
'original'=>$this->min_original,
|
|
'description'=>$this->description,
|
|
'content'=> str_replace('/uploads/images', 'http://www.bohaimingpin.com/uploads/images',$this->content),
|
|
'tag' =>[
|
|
'is_new'=> $this->is_recommend == 1 ? true : false,
|
|
],
|
|
],
|
|
'seller'=>[
|
|
'id'=>$this->seller_id,
|
|
'name'=>$this->seller->name ?? '',
|
|
'logo'=>$this->seller->storage_id ? $this->seller->storage ? 'http://www.bohaimingpin.com'.$this->seller->storage->path : '' : '',
|
|
'description'=>$this->seller->description,
|
|
|
|
],
|
|
'attribute'=> GoodsParamsResource::collection($this->params()->where('status', 1)->where('stock', '>', 0)->where('score', '>', 0)->whereRaw('price = score')->get()),
|
|
|
|
];
|
|
}
|
|
}
|