0
0
Files
Babyclass/app/Api/Resources/GoodsGiftDetailResource.php
2020-08-04 10:09:42 +08:00

36 lines
1.3 KiB
PHP

<?php
namespace App\Api\Resources;
use Illuminate\Http\Resources\Json\JsonResource;
class GoodsGiftDetailResource 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' => number_format($this->params()->orderBy('price','desc')->first()->price,2),
'description'=>$this->description,
'content'=> str_replace('/uploads/images', 'http://www.bohaimingpin.com/uploads/images',$this->content),
'params_id'=>$this->params()->orderBy('price','desc')->first()->id,
],
'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,
]
];
}
}