tp5 each()与分页
程序员文章站
2022-05-03 19:53:21
...
tp5 each()与分页,
public function each(){
$uid = input('uid');
$groupList = model('grouping')->where(['uid' => $uid, 'elite' => 9])->field('groupid,groupname')->paginate(1, false, ['query' => request()->param()])->each(function ($item, $key) use ($uid) {
//向每个分组中加入状态字段
$item['status'] = 0; //不正常
//取此分组下正常的人
$userid = model('user')->where(['uid' => $uid, 'groupid' => $item['groupid']])->where(function ($query) {
$query->where(['status' => 1])->whereor(['login_status' => 1]);
})->value('uid');
if ($userid) {
$item['status'] = 1; //正常
}
})->toArray();
}
做一下记录,方便日后查询。