合并不同的集合后,我需要保持分页,该集合具有相同的结构。
代码
$allclients = collect();
foreach($User as $user){
$clients = Users::where('status', 'LIKE', $stat.'%')->orderBy('name')->paginate($this->pagination);
if($allclients->isEmpty()){
$allclients = $clients;
}
$allclients = $allclients->merge($clients);
}
当我使用merge()时,我的分页消失了。
答案 0 :(得分:0)
尝试一下:
$clients = Users::where('status', 'LIKE', $stat.'%')->orderBy('name')->paginate($this->pagination);
$clients = collect($clients->items());
$allclients = $allclients->merge($clients);
答案 1 :(得分:0)
我将$ stat更改为array(),删除了foreach
$clients = Users::whereIn('status', $stat)->orderBy('name')->paginate($this->pagination);