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

26 lines
710 B
PHP

<?php
namespace App\Api\Resources;
use Illuminate\Http\Resources\Json\JsonResource;
class GoodsGiftListResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function toArray($request)
{
return [
'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' => mb_substr($this->description, 0, 60)
];
}
}