//查询用户的粉丝
$fans = $user->fans;
$fusers = User::alias('u')
->join('profile p', 'u.id = p.user_id')
->when($keyword, function ($query) use ($keyword) {
$query->where('p.nickname', 'like', "%{$keyword}%");
})
->withCount(['articles', 'fans'],false)
->whereIn('u.id', $fans->column('fan_id'))
->where('u.status', 1)
->paginate([
'list_rows' => $this->pagesize,
'query' => [
'keyword' => $keyword,
]
]);
关键点在于 withCount 第二个参数要为false