From 47a7aa345a81f40b7f96d4264c006c5dbd0f2543 Mon Sep 17 00:00:00 2001 From: "HESU\\HESU" <1696136552@qq.com> Date: Tue, 1 Apr 2025 15:08:52 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A0=87=E7=AD=BE=E5=85=B3=E8=81=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controller/CustomerController.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/app/controller/CustomerController.php b/app/controller/CustomerController.php index 446e1fa..1615ea4 100644 --- a/app/controller/CustomerController.php +++ b/app/controller/CustomerController.php @@ -169,11 +169,14 @@ class CustomerController // 执行分页查询 //关联标签tags //关联标签及分组tags.group $query = Customer::with('tags')->where($where) - ->orderBy('id', 'desc'); + ->orderBy('customer.id', 'desc'); if(!empty($tagId)){ - $query->with(['tags' => function($query) use ($tagId){ - $query->where('id', $tagId); - }]); +// $query->with(['tags' => function($query) use ($tagId){ +// $query->where('tag.id', $tagId); +// }]); + $query->whereHas('tags', function($query) use ($tagId){ + $query->where('tag.id', $tagId); + }); } if (!Util::isEmpty($keyword)) { $query->where(function ($query) use ($keyword) {