cacheSelect = true; $pageSize = 100; $list = Brand::getBrands(); if (isset(\YunShop::request()->is_recommend)) { $is_recommend = intval(\YunShop::request()->is_recommend); $list = $list->where('is_recommend',intval($is_recommend)); } $list = $list->paginate($pageSize)->toArray(); if($list['data']){ foreach ($list['data'] as &$item) { $item['logo'] = replace_yunshop(yz_tomedia($item['logo'])); } return $this->successJson('获取品牌数据成功!', $list); } return $this->errorJson('未检测到品牌数据!', $list); } public function getBrandGoods() { $id = intval(\YunShop::request()->id); if (!$id) { return $this->errorJson('请传入正确参数.'); } $brand_detail = Brand::uniacid()->select("name", "logo", "id", "desc")->find($id); if (!$brand_detail) { return $this->errorJson('品牌已被删除或不存在...'); } if ($brand_detail->logo) { $brand_detail->logo = yz_tomedia($brand_detail->logo); } $brand_detail->desc = html_entity_decode($brand_detail->desc); $list = Goods::select('id', 'id as goods_id', 'title', 'thumb', 'price', 'market_price','plugin_id') ->where("status", 1) ->where(function($query) { //$query->where("plugin_id", 0)->orWhere('plugin_id', 40)->orWhere('plugin_id', 92); $query->whereIn("plugin_id", [0,40,92,44]); })->where('brand_id', $id)->orderBy('display_order', 'desc') ->paginate(20)->toArray(); if ($list['total'] > 0) { $data = collect($list['data'])->map(function($rows) { return collect($rows)->map(function($item, $key) { if ($key == 'thumb') { return replace_yunshop(yz_tomedia($item)); } else { return $item; } }); })->toArray(); $list['data'] = $data; } if (empty($list)) { return $this->errorJson('该品牌下没有商品.'); } $brand_detail['goods'] = $list; return $this->successJson('成功', $brand_detail); } public function getBrandDetail() { $id = intval(\YunShop::request()->id); if (!$id) { return $this->errorJson('请传入正确参数.'); } $brand_detail = Brand::uniacid()->select("name", "logo", "id", "desc")->find($id); if (!$brand_detail) { return $this->errorJson('品牌已被删除或不存在...'); } if ($brand_detail->logo) { $brand_detail->logo = yz_tomedia($brand_detail->logo); } $brand_detail->desc = html_entity_decode($brand_detail->desc); return $this->successJson('brand_detail', $brand_detail); } }