| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- <?php
- namespace Modules\Api\Responses;
- use App\Contracts\Responsable;
- use App\Repositories\Utils\M3u8CacheRepository;
- class OriginalGoodsListsResponse implements Responsable
- {
- /**
- * 录入的数据.
- *
- * @var mixed
- */
- private $data = null;
- /**
- * @var string
- */
- private $adList;
- public function __construct($data = null, $adList = [])
- {
- $this->data = $data;
- $this->adList = $adList;
- }
- public function toResponse($request = null)
- {
- $res = $this->data;
- if (!empty($res)) {
- foreach ($res->items() as &$item) {
- $item->cover = M3u8CacheRepository::getImageUrl($item->cover);
- $item->shop_cover = M3u8CacheRepository::getImageUrl($item->shops->cover);
- $item->shop_name = $item->shops->title;
- $item->credit_value = $item->shops->credit_value;
- unset($item->shops_uid);
- unset($item->shops);
- }
- }
- $res = $res->toArray();
- $res['ad'] = $this->adList;
- return json_success($res);
- }
- }
|