From 7e569330d7cd2b98c3b992645345414981cb7834 Mon Sep 17 00:00:00 2001 From: Edward Yang Date: Fri, 13 Jan 2023 15:51:49 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E6=A0=BC=E5=BC=8F=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- beike/Repositories/ProductRepo.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/beike/Repositories/ProductRepo.php b/beike/Repositories/ProductRepo.php index 6323dfd2..498792eb 100644 --- a/beike/Repositories/ProductRepo.php +++ b/beike/Repositories/ProductRepo.php @@ -191,11 +191,13 @@ class ProductRepo return $attributes; } - public static function getFilterAttribute($data) + public static function getFilterAttribute($data): array { - $builder = self::getBuilder($data)->with(['attributes.attribute.description', 'attributes.attribute_value.description'])->leftJoin('product_attributes as pa', 'pa.product_id', 'products.id') - ->whereNotNull('pa.attribute_id') + $builder = self::getBuilder($data) ->select(['pa.attribute_id', 'pa.attribute_value_id']) + ->with(['attributes.attribute.description', 'attributes.attribute_value.description']) + ->leftJoin('product_attributes as pa', 'pa.product_id', 'products.id') + ->whereNotNull('pa.attribute_id') ->distinct() ->reorder('pa.attribute_id'); $productAttributes = $builder->get()->toArray();