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) {