search($where)->with(['user', 'record' => function ($query) { $query->where('is_follow', 1)->whereDay('add_time', 'yesterday')->field('qid,count(distinct uid) as number')->bind(['y_follow' => 'number']); }])->when($page && $limit, function ($query) use ($page, $limit) { $query->page($page, $limit); })->order('id desc')->select()->toArray(); } /** * 更新次数 * @param $id * @param $isFollow */ public function upFollowAndScan($id, $isFollow) { $this->getModel()->where('id', $id)->inc('scan')->when($isFollow, function ($query) { $query->inc('follow'); })->update(); } }