|
@@ -13,7 +13,7 @@ class CategoryService extends BaseService
|
|
|
{
|
|
|
public function paginate($params)
|
|
|
{
|
|
|
- $p = Category::query()->when($params['level'], function (Builder $query) use ($params) {
|
|
|
+ $p = Category::query()->with(["parent", "childS", "gcMap"])->when($params['level'], function (Builder $query) use ($params) {
|
|
|
return $query->where("level", $params['level']);
|
|
|
})->when($params['name'], function (Builder $query) use ($params) {
|
|
|
return $query->where(function (Builder $query) use ($params) {
|
|
@@ -33,8 +33,8 @@ class CategoryService extends BaseService
|
|
|
"level" => $model->level,
|
|
|
"parent_id" => optional($model->parent)->id ?? 0,
|
|
|
"parent_name" => optional($model->parent)->name ?? "",
|
|
|
- "child_category_count" => 1, #TODO
|
|
|
- "child_goods_count" => 1, #TODO
|
|
|
+ "child_category_count" => $model->childS->count(),
|
|
|
+ "child_goods_count" => $model->gcMap->count(),
|
|
|
"weight" => $model->weight,
|
|
|
"index_weight" => $model->index_weight,
|
|
|
"category_weight" => $model->category_weight,
|