|
@@ -129,7 +129,11 @@ class PageService extends BaseService
|
|
$gidArr = GoodsCategoryMap::where("category_id", $cidArr)->get(['goods_id'])->pluck("goods_id")->unique()->toArray();
|
|
$gidArr = GoodsCategoryMap::where("category_id", $cidArr)->get(['goods_id'])->pluck("goods_id")->unique()->toArray();
|
|
$attrMap = [];
|
|
$attrMap = [];
|
|
if ($attrs = Arr::get($params, "attrs", [])) {
|
|
if ($attrs = Arr::get($params, "attrs", [])) {
|
|
- $attrMap = json_decode($attrs, true);
|
|
|
|
|
|
+ if (is_array($attrs)) {
|
|
|
|
+ $attrMap = $attrs;
|
|
|
|
+ } else {
|
|
|
|
+ $attrMap = json_decode($attrs, true);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
$p = Goods::where("status", Goods::STATUS_OK)->when($params['keyword'], function (Builder $query) use ($params) {
|
|
$p = Goods::where("status", Goods::STATUS_OK)->when($params['keyword'], function (Builder $query) use ($params) {
|
|
$query->where("name", "like", "%" . $params['keyword'] . "%");
|
|
$query->where("name", "like", "%" . $params['keyword'] . "%");
|
|
@@ -163,7 +167,11 @@ class PageService extends BaseService
|
|
{
|
|
{
|
|
$attrMap = [];
|
|
$attrMap = [];
|
|
if ($attrs = Arr::get($params, "attrs", [])) {
|
|
if ($attrs = Arr::get($params, "attrs", [])) {
|
|
- $attrMap = json_decode($attrs, true);
|
|
|
|
|
|
+ if (is_array($attrs)) {
|
|
|
|
+ $attrMap = $attrs;
|
|
|
|
+ } else {
|
|
|
|
+ $attrMap = json_decode($attrs, true);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
$pageSize = Arr::get($params, "page_size", 10);
|
|
$pageSize = Arr::get($params, "page_size", 10);
|
|
$p = Goods::where("status", Goods::STATUS_OK)->when($attrMap, function (Builder $query) use ($attrMap) {
|
|
$p = Goods::where("status", Goods::STATUS_OK)->when($attrMap, function (Builder $query) use ($attrMap) {
|